Mercurial > op > Looping
view Looping.php @ 4:d788c88f41bd >>178
Rubyのベンチマークを追加。ソースコードは2ch.netの>>178からコピー。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Thu, 17 Feb 2011 09:01:50 +0900 |
parents | b99b69fd33aa |
children |
line wrap: on
line source
#!/usr/bin/env php <?php class Looping { private $n0 = 0; public function calc($n) { $n1 = $this->n0 + (1 - 2*($n%2)); $this->n0 = $n; return $n1; } } $s = new Looping(); $c = 0; $n = 1; $t1 = microtime(true); while ($c<2147483647) { $n = $s->calc($n); $c++; } $t2 = microtime(true); echo $n, " PHP\t", ($t2-$t1), "\n";