Skip to content

Instantly share code, notes, and snippets.

@sandacn
Created April 16, 2011 09:13
Show Gist options
  • Save sandacn/923002 to your computer and use it in GitHub Desktop.
Save sandacn/923002 to your computer and use it in GitHub Desktop.
## 测试到底是i++ 快还是 ++i快
<?php
## 测试到底是i++ 快还是 ++i快
$MAX = 1000000;
$start_ts = microtime(true);
for ($i = 0; $i < $MAX; $i++) {
$a = 1;
}
$end_ts = microtime(true);
var_dump($end_ts - $start_ts);
$start_ts = microtime(true);
for ($i = 0; $i < $MAX; ++$i) {
$a = 1;
}
$end_ts = microtime(true);
var_dump($end_ts - $start_ts);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment