Skip to content

Instantly share code, notes, and snippets.

@joshtronic
Last active March 20, 2019 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joshtronic/8310309ab2810a6ecfde to your computer and use it in GitHub Desktop.
Save joshtronic/8310309ab2810a6ecfde to your computer and use it in GitHub Desktop.
Basic PHP benchmarking template
<?php
$n = 1000000;
$start_time = microtime(true);
$start_mem = memory_get_usage(true);
for ($i = 0; $i < $n; $i++)
{
}
$time = microtime(true) - $start_time;
$mem = memory_get_usage(true) - $start_mem;
echo "Test 1\t{$time}\t{$mem}\n";
// Duplicate lines 5-16 for each block of code you want to test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment