Skip to content

Instantly share code, notes, and snippets.

@jeffjrare
Created February 21, 2014 17:24
Show Gist options
  • Save jeffjrare/9138822 to your computer and use it in GitHub Desktop.
Save jeffjrare/9138822 to your computer and use it in GitHub Desktop.
Array test
Apc: 0.0036849975585938 seconds
Spl: 0.00083422660827637 seconds
Std: 0.00088095664978027 seconds
<?php
/**
*
* PLEASE DONT DELETE THIS FILE
*
* @author jeffgirard
*
*/
include "secret_includes/connect.php";
//ini_set("memory_limit","800M");
//set_time_limit(300);
// apc
$apcStart=microtime(true);
$arr=array();
for ($i = 0; $i < 3000; $i++){
$arr[] = $i;
}
apc_store('arr', $arr);
foreach(apc_fetch('arr') as $item){
//echo $item;
}
echo "<br>Apc: ".(microtime(true)-$apcStart).' seconds<br><br>';
// spl
$splStart=microtime(true);
$arr=new SplFixedArray(3000);
for ($i = 0; $i < 3000; $i++){
$arr[$i] = $i;
}
foreach($arr as $item){
//echo $item;
}
echo "<br>Spl: ".(microtime(true)-$splStart).' seconds<br><br>';
// std
$stdStart=microtime(true);
$arr=array();
for ($i = 0; $i < 3000; $i++){
$arr[] = $i;
}
foreach($arr as $item){
//echo $item;
}
echo "<br>Std: ".(microtime(true)-$stdStart).' seconds<br><br>';
debug_output_full();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment