Advertisement
kiler129

Untitled

Jul 7th, 2014
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2. //Test file for case >>for_precalc<< [test ID: num_array_read-for_vs_foreach]
  3. //Generated at Mon, 07 Jul 2014 23:09:13 +0200
  4.  
  5.  
  6. /*************** ./c4_env.inc.php START ***************/
  7.     gc_disable();
  8.     $_c4Results = array();
  9.     function _startC4Timer() { $GLOBALS["_c4ts"] = microtime(true); }
  10.     function _stopC4Timer() { return microtime(true)-$GLOBALS["_c4ts"]; }
  11.     function _startC4Mem() {}
  12.     function _stopC4Mem() { return -1; } //TODO: memory functions
  13.     function startC4() {
  14.         _stopC4Mem();
  15.         _startC4Timer();
  16.     }
  17.    
  18.     function stopC4() {
  19.         echo die(json_encode(array("time" => _stopC4Timer(), "mem" => _stopC4Mem())));
  20.     }
  21. /*************** ./c4_env.inc.php END ***************/
  22.  
  23.  
  24. /*************** ./tests/num_array_read-for_vs_foreach/__init.inc.php START ***************/
  25.     $smallArray = range(0,3);
  26.     $mediumArray = range(0,100);
  27.     $bigArray = range(0,1000);
  28.     $hugeArray = range(0,10000);
  29. /*************** ./tests/num_array_read-for_vs_foreach/__init.inc.php END ***************/
  30.  
  31. /*** Test case with 1000 iteration(s) ***/
  32. startC4();
  33. for($i=0; $i<1000; $i++) {
  34.  
  35. /*************** ./tests/num_array_read-for_vs_foreach/for_precalc.c4.php START ***************/
  36.     $size = count($smallArray);
  37.     for($i=0; $i<$size; $i++) $tmp = $smallArray[$i];
  38.    
  39.     $size = count($mediumArray);
  40.     for($i=0; $i<$size; $i++) $tmp = $mediumArray[$i];
  41.    
  42.     $size = count($bigArray);
  43.     for($i=0; $i<$size; $i++) $tmp = $bigArray[$i];
  44.    
  45.     $size = count($hugeArray);
  46.     for($i=0; $i<$size; $i++) $tmp = $hugeArray[$i];
  47. /*************** ./tests/num_array_read-for_vs_foreach/for_precalc.c4.php END ***************/
  48.  
  49. }
  50.  
  51. stopC4();
  52.  
  53. //END OF CASE FILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement