Skip to content

Instantly share code, notes, and snippets.

@BRMatt
Created April 18, 2009 17:50
Show Gist options
  • Save BRMatt/97712 to your computer and use it in GitHub Desktop.
Save BRMatt/97712 to your computer and use it in GitHub Desktop.
<?php
Class Increment extends CodeBench
{
public $description = 'Comparision of $i++ to ++$i';
public $loops = 10000;
public $subjects = array(
// Kinda sporadic jumps, but show a noticeable gap as value increases
100,
200,
300,
500,
700,
1000,
10000,
100000,
);
/**
* This should be the fastest
**/
function bench_pp_i($max)
{
for ($i = 0; $i < $max; ++$i)
{
}
}
/**
* This should be the slowest
**/
function bench_i_pp($max)
{
for ($i = 0; $i < $max; $i++)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment