Mercurial > op > Looping
comparison Looping.php @ 2:b99b69fd33aa
PHPのベンチマークを追加。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Tue, 15 Feb 2011 18:38:48 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:9d6fb29e41ce | 2:b99b69fd33aa |
---|---|
1 #!/usr/bin/env php | |
2 <?php | |
3 class Looping | |
4 { | |
5 private $n0 = 0; | |
6 public function calc($n) { | |
7 $n1 = $this->n0 + (1 - 2*($n%2)); | |
8 $this->n0 = $n; | |
9 return $n1; | |
10 } | |
11 } | |
12 | |
13 $s = new Looping(); | |
14 $c = 0; | |
15 $n = 1; | |
16 $t1 = microtime(true); | |
17 while ($c<2147483647) { | |
18 $n = $s->calc($n); | |
19 $c++; | |
20 } | |
21 $t2 = microtime(true); | |
22 echo $n, " PHP\t", ($t2-$t1), "\n"; |