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 0 You must be signed in to fork a gist
  • Save odino/794293 to your computer and use it in GitHub Desktop.
Save odino/794293 to your computer and use it in GitHub Desktop.
<?php
//
//
//// Decide how many children to use.
$children = 10;
// Load Predis. If using PHP 5.2, call new Predis_Client() instead.
$predis = new Redis();
$predis->connect('127.0.0.1', 6379);
// If the dataset is not ready, generate it. THIS WILL DESTROY EXISTING DATA!
if ($predis->dbsize() != 100001 || !$predis->exists('trigger'))
{
echo "Generating 100,000 keys for testing ...\n";
$predis->flushdb();
$start = microtime(true);
for ($i = 0; $i < 10; $i++)
{
for ($j = 0; $j < 100; $j++)
{
for ($k = 0; $k < 100; $k++)
{
$predis->set("key:$i:$j:$k", "value:$i:$j:$k");
}
}
$gen = number_format(($i + 1) * 10000);
echo "Generated $gen keys ...\n";
}
$benchmark = number_format(microtime(true) - $start, 3);
$set_per_sec = number_format(100000 / $benchmark);
echo "Done in $benchmark seconds ($set_per_sec SET/s)\n\n";
}
else
{
echo "Dataset OK (100,000 keys)\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment