Anyone else have this issue? Even if I write a simple hello world! script with a shebang and run it, there seems to be a half a second or so delay before I get my response.

#!/usr/bin/php
<?php

echo "Hello World!";

?>

If I write the same script in either Bash, Python or Perl, the response is instant. Anyone else notice this?

    You're on a *nix aren't you?
    Try

    time /path/to/script
    

    For my hello world script I get

    hello world
    
    real    0m0.117s
    user    0m0.016s
    sys     0m0.003s
    

      You're on a *nix aren't you?

      Yeah... Gentoo. At work at the moment, never really thought of timing it though. Its just plain slow. So slow if fact that Im thinking Im not going to use it.

      Could this at all be caused by the amount of extensions I haver built into php? This is my dev machine so Its pretty much got everything built in and configured.

      I'll post my results tommorow (no net at home atm), but its real slow compared to Python or Bash.

      I'll post my ./configure tommoz aswell.

        At a guess I'd say it's to do with loading extensions. Do you have any large ones or is PHP compiled with lots in?
        As I understand it (not really used python much) you import libraries as an when you need them in python (like most sensible languages:rolleyes🙂 so if you don't need to do much, you don't have much startup overhead.

          Php has allot compiled in. Most all of them actually. That may indeed be my problem. If that is the case, I guess I can slim down my cli version. And yeah your right about python, include as you need.

          But yeah, just moved house, no net at the moment, and updating / compiling anything on gentoo is pretty much impossible without the net.

          Thanks for your thoughts.

            yeah it is related to the overhead associated with creating a PHP instance. This is one reason why you don't want to run PHP as CGI on a web server, because it is a bit slow since each request creates a new instance. FastCGI is better, since it keeps a pool of instances to reuse. Don't think there is anything like this for the CLI though.

            I've got quite a bit compiled in (and loading in php.ini) as well, but get about the same time as bubblenut gets... but it nearly doubles if I turn Xdebug on, which I would expect given all that extension has to do. [PHP 5]

            You can dynamically load libraries in PHP as well only when you need them, but most people don't use that feature since most hosts just compile everything in instead of compiling most extensions as standalone modules that people can load in when they need to.

              Write a Reply...