home » knowledge base » Benchmarking php code fragments (2006-01-15)

Tags: code snippet (6) php (2)

Benchmarking php code fragments

Here's how to do it:

function getmicrotime()
{
        $t = microtime();
        $t = explode(' ',$t);
        return (float)$t[1]+ (float)$t[0];
}

function dobench1($ITER)
{
        bench1();
        $t1 = getmicrotime();
        for ($i=$ITER; --$i >= 0;) {
                bench1();
        }
        return getmicrotime() - $t1;
}
Tags: code snippet (6) php (2)


Krzysztof Kowalczyk