changeset 2:b99b69fd33aa

PHPのベンチマークを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Tue, 15 Feb 2011 18:38:48 +0900
parents 9d6fb29e41ce
children 57283e4fdd4b
files Looping.php
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Looping.php	Tue Feb 15 18:38:48 2011 +0900
@@ -0,0 +1,22 @@
+#!/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";