Created
December 3, 2015 23:47
-
-
Save herewithme/e61a7399c1bd1b130e11 to your computer and use it in GitHub Desktop.
Benchmark for test memcached performance
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 | |
// Initialize values: 1000000 keys of 20 bytes with 40 bytes of data | |
$c = 1000000; | |
$values = array(); | |
for ($i=0;$i<$c;$i++) $values[sprintf('%020s',$i)]=sha1($i); | |
// Memcached | |
$m = new Memcached(); | |
$m->addServer('10.0.101.82', 11211); | |
$start = microtime(true); | |
foreach ($values as $k => $v) $m->set($k, $v, 3600); | |
$time = microtime(true)-$start; | |
echo "memcached set: $time\n"; | |
$start = microtime(true); | |
foreach ($values as $k => $v) $m->get($k); | |
$time = microtime(true)-$start; | |
echo "memcached get: $time\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment