Last active
February 11, 2016 21:19
-
-
Save arielallon/8841e499202f5eb48689 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
function wasteMemory($redis, $runs, $multi=false, $echoEvery=10000) { | |
if ($multi) { | |
$redis->multi(); | |
} | |
for ($i=0; $i <= $runs; $i++) { | |
$redis->set('key'.$i, 'value'.$i); | |
if ($i % $echoEvery === 0) { | |
echo memory_get_peak_usage(); | |
echo "\n"; | |
} | |
} | |
if ($multi) { | |
$redis->exec(); | |
} | |
} | |
$redis = new Redis(); | |
$redis->connect('127.0.0.1', 6379); | |
wasteMemory($redis, 100000); | |
/** shell output | |
241608 | |
241608 | |
241608 | |
241608 | |
241608 | |
241608 | |
241608 | |
241608 | |
241608 | |
241608 | |
241608 | |
*/ | |
wasteMemory($redis, 100000, true); | |
/** shell output | |
245840 | |
245840 | |
245840 | |
245840 | |
245840 | |
245840 | |
245840 | |
245840 | |
245840 | |
245840 | |
245840 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment