Created
February 20, 2013 02:11
-
-
Save eb-eoliveira/4992122 to your computer and use it in GitHub Desktop.
Fatcache second test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$m = new Memcached(); | |
$m->addServer('localhost', 11211, 33); | |
$items = 500000; | |
$keysToGet = array(); | |
for ($i = 1; $i <= $items; ++$i) { | |
$key = md5(rand()); | |
$value = md5(rand()). md5(rand()) . md5(rand()) . md5(rand()) . md5(rand()); | |
$m->set($key, $value, rand(60, 600)); | |
if (rand(1,10) == 1) { | |
$keysToGet[] = $key; | |
} | |
} | |
echo "Sleeping...\n"; | |
sleep(10); // give enough time to flush to disk | |
// add more keys to replace the hot keys inserted before | |
for ($i = 1; $i <= $items; ++$i) { | |
$key = md5(rand()); | |
$value = md5(rand()). md5(rand()) . md5(rand()) . md5(rand()) . md5(rand()); | |
$m->set($key, $value, rand(60, 600)); | |
} | |
$start = time(); | |
foreach ($keysToGet as $key) { | |
$m->get($key); | |
} | |
$end = time(); | |
echo "\nSummary\n"; | |
echo "Items: " . count($keysToGet) . "\n"; | |
echo "Start time: $start\n"; | |
echo "End time: $end\n"; | |
echo "Operations/s: " . (count($keysToGet)/($end-$start)) . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment