Permalink
Browse files

Added array push benchmark for php

  • Loading branch information...
felixge committed Sep 23, 2010
1 parent f007edf commit 4312cd24ef10b716c0f20a52f55a2863cd982c71
Showing with 19 additions and 0 deletions.
  1. +3 −0 Makefile
  2. +16 −0 benchmark/php/array-push.php
View
@@ -7,6 +7,9 @@ benchmark-v8:
benchmark-php:
@find benchmark/php/*.php | xargs -n 1 -t php
+benchmark-all: benchmark-v8 benchmark-php
+ @find benchmark/*.js | xargs -n 1 -t node
+
benchmark:
@find benchmark/*.js | xargs -n 1 -t node
@@ -0,0 +1,16 @@
+<?php
+ini_set('memory_limit', '256M');
+
+$COUNT = 1e6;
+$a = array();
+
+$start = microtime(true);
+for ($i = 0; $i < $COUNT; $i++) {
+ array_push($a, $i);
+}
+
+$ms = (microtime(true) - $start) * 1000;
+$mhz = ((($COUNT / ($ms / 1000)) / 1e6));
+$million = $COUNT / 1e6;
+
+echo sprintf("%.2f Mhz (%d million in %d ms)\n", $mhz, $million, $ms);

0 comments on commit 4312cd2

Please sign in to comment.