Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.