All pastes #70781 Raw Edit

merlinofchaos

public php v1 · immutable
#70781 ·published 2006-06-24 20:42 UTC
rendered paste body
Drupal 4.7, old cache, 10,000 entries prefilled to create some data in the table:execution 15000 iterations    * Start Time Sat, 2006-06-24 20:39    * Read time 6 sec (833.33333333333 per sec)    * Write time 11 sec (454.54545454545 per sec)execution 25000 iterations    * Start Time Sat, 2006-06-24 20:39    * Read time 6 sec (833.33333333333 per sec)    * Write time 11 sec (454.54545454545 per sec)execution 35000 iterations    * Start Time Sat, 2006-06-24 20:40    * Read time 5 sec (1000 per sec)    * Write time 11 sec (454.54545454545 per sec)HEAD running cache patchexecution 15000 iterations    * Start Time Sat, 2006-06-24 20:40    * Read time 6 sec (833.33333333333 per sec)    * Write time 10 sec (500 per sec)5000 iterations    * Start Time Sat, 2006-06-24 20:41    * Read time 7 sec (714.28571428571 per sec)    * Write time 11 sec (454.54545454545 per sec)5000 iterations    * Start Time Sat, 2006-06-24 20:41    * Read time 5 sec (1000 per sec)    * Write time 11 sec (454.54545454545 per sec)Code run:<?phpfunction test_menu($may_cache) {  if ($may_cache) {    $items[] = array(      'path' => 'test/reset',      'callback' => 'test_reset',      'title' => 'reset bench cache',      'access' => true,      'type' => MENU_NORMAL_ITEM    );    $items[] = array(      'path' => 'test/bench',      'callback' => 'test_bench',      'title' => 'bench cache',      'access' => true,      'type' => MENU_NORMAL_ITEM    );  }  return $items;}function test_reset() {  cache_clear_all();  foreach (range(0, 10000) as $i) {    $j = md5($i);    cache_set("temp:$j", $j . md5($i*$i) . md5($i*$i*$i));  }}function test_bench($iter = 1000) {  $start = time();  // read iter entries  foreach (range(0, $iter) as $i) {    $j = md5($i);    cache_get("temp:$j");  }  $post_read = time();  // write iter entries  foreach (range(0, $iter) as $i) {    $j = md5($i);    cache_set("temp:$j", $j . md5($i*$i) . md5($i*$i*$i));  }  $post_write = time();  $post_del = time();  $items[] = 'Start Time ' . format_date($start);  $read_time = $post_read - $start;  $items[] = 'Read time ' . format_interval($read_time) . ' (' . ($iter / $read_time) . ' per sec)';  $write_time = $post_write - $post_read;  $items[] = 'Write time ' . format_interval($write_time) . ' (' . ($iter / $write_time) . ' per sec)';  return theme('item_list', $items, "$iter iterations");}