Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // simple operations timing in PHP
- // Note this is not really a good measure of any language.
- // Who iterates over 1 million items and calls a function every time?
- function addone($x) {
- return $x+1;
- }
- $t0 = microtime(TRUE);
- $x = 0;
- for ($i=0; $i<1000000; $i++) {
- $x=addone($x);
- }
- $t1 = microtime(TRUE);
- print ($t1 - $t0);
- echo "\n";
- $t0 = microtime(TRUE);
- $x = 0;
- for ($i=0; $i<1000000; $i++) {
- $x=$x+1;
- }
- $t1 = microtime(TRUE);
- print ($t1 - $t0);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement