|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-02-19 18:35 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
Using passthru("whatever") is almost 100 times slower than doing the equivalent $out = `whatever`;echo $out I tested this using the following program (I use dd here to generate the data, but the same results appear with any command, cat /etc/passwd etc.) <?php echo "<!--"; $start = microtime(); passthru("dd if=/dev/zero count=100"); $end = microtime(); echo "-->"; $mt = explode(' ', $start); $mts = $mt[1] + $mt[0]; $mt = explode(' ', $end); $mte = $mt[1] + $mt[0]; printf("%.3f seconds elapsed (passthru)<p>", $mte - $mts); echo "<!--"; $start = microtime(); $out = `dd if=/dev/zero count=100`; echo $out; $end = microtime(); echo "-->"; $mt = explode(' ', $start); $mts = $mt[1] + $mt[0]; $mt = explode(' ', $end); $mte = $mt[1] + $mt[0]; printf("%.3f seconds elapsed (backquotes)<p>", $mte - $mts); ?> On my machine (Pentium 400) this script outputs: 16.231 seconds elapsed (passthru) 0.266 seconds elapsed (backquotes) Quite a difference, I think. Compiled with: ./configure \ --bindir=/usr/local/apache/bin \ --libdir=/usr/local/apache/php/lib \ --with-apxs=/usr/local/apache/bin/apxs \ --with-config-file-path=/usr/local/apache/conf \ --with-exec-dir=/usr/local/apache/php/bin \ --with-pear=/usr/local/apache/php/lib \ --enable-safe-mode \ --with-openssl=/usr/local/ssl \ --with-imap=shared,/usr/local \ --enable-dbx=shared \ --enable-dio=shared \ --enable-ftp \ --with-sybase-ct=shared,/usr/local \ --with-mysql=shared,/usr/local/mysql \ --with-pgsql=shared,/usr/local/pgsql \ --with-gdbm=shared \ --with-zlib=/usr/local \ --with-gd=shared \ --enable-exif=shared \ --enable-ctype \ --with-gettext \ --with-xml=shared \ --with-expat-dir=/usr/local \ --enable-xslt=shared \ --with-xslt-sablot=/usr/local \ --enable-sockets=shared \ --enable-wddx=shared \ --enable-shmop=shared \ --enable-sysvmsg=shared \ --enable-sysvsem=shared \ --enable-sysvshm=shared