midgard_php_cache VS memcache

Posted on 2007-04-20 12:57:39 EEST.

Time for a "benchmark". Let me know if you think the simple code I used is wrong.

I created two loops. 10000 steps per each.

for ($i = 0; $i < 10000; $i++) {

}

In first loop I used:

$_kv = "a".$i;
$memcache->set($_kv, $_kv);

In the second:

$_kv = "a".$i;
$memcache->get($_kv);

Next I replaced memcache object with midgard_php_cache one, and invoked almost the same methods. Simply I created 10000 arrays like this one:

"aX" => "aX"

Average time for both loops:

  • memcache 0,9749
  • midgard_php_cache 0,0525

Average time for only second loop:

  • memcache 0,505
  • midgard_php_cache 0,0369

In latter case I also printed values returned by both objects to make sure I get some data. Apache has been not restarted and I got expected values ( a1, a2, a3....) in both cases. Which looks like values has been cached among all requests.

I just wonder... why difference is so noticable?

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS