|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22308 passthru is extremely slow
Submitted: 2003-02-19 16:55 UTC Modified: 2003-02-19 18:35 UTC
From: uk at dataway dot ch Assigned:
Status: Closed Package: Performance problem
PHP Version: 4.3.0 OS: Linux 2.2.18
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: uk at dataway dot ch
New email:
PHP Version: OS:


 [2003-02-19 16:55 UTC] uk at dataway dot ch
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.)

        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 \


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-19 18:35 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 18:01:34 2024 UTC