Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP - Aspas duplas - Benchmark
<?php
// inicio
$rustart = getrusage();
// codigo
for($x = 0; $x < 100000; $x++)
{
$a = "Indice-$x";
}
// fim
function rutime($ru, $rus, $index) {
return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000))
- ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000));
}
$ru = getrusage();
echo "Este processo usou " . rutime($ru, $rustart, "utime") .
" ms para seu processamento\n";
echo "Este processo custou " . rutime($ru, $rustart, "stime") .
" ms em chamadas internas do sistema\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment