Skip to content

Instantly share code, notes, and snippets.

@odino
Created January 25, 2011 00:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save odino/794294 to your computer and use it in GitHub Desktop.
Save odino/794294 to your computer and use it in GitHub Desktop.
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
for ($i = 0; $i < 100; $i++) {
$start = microtime(true);
for ($j = 0; $j < 10000; $j++) {
$key = sprintf("key:%05d", $j);
/* GET or SET */
if (rand() % 2 == 0) {
$redis->set($key, rand());
} else {
$redis->get($key);
}
}
$time = microtime(true)-$start;
printf("%6d req/sec\n", $j/$time);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment