Skip to content

Instantly share code, notes, and snippets.

@HaiBV
Last active November 22, 2019 09:40
Show Gist options
  • Save HaiBV/bce9461fc946d632784abbf3e9bf1113 to your computer and use it in GitHub Desktop.
Save HaiBV/bce9461fc946d632784abbf3e9bf1113 to your computer and use it in GitHub Desktop.
Benchmarking PHP code block
$n = 1000000;
$time1 = microtime(true);
$mem1 = memory_get_usage(true);
for ($i = 0; $i < $n; $i++)
{
}
$time2 = microtime(true);
$mem2 = memory_get_usage(true);
echo "Test 1: time " . $time2 - $time1 . " - mem " . $mem2 - $mem1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment