Skip to content

Instantly share code, notes, and snippets.

@hkulekci
Last active August 29, 2015 14:10
Show Gist options
  • Save hkulekci/f5106e5c574e6f99a367 to your computer and use it in GitHub Desktop.
Save hkulekci/f5106e5c574e6f99a367 to your computer and use it in GitHub Desktop.
Redis lpush and rpop test on my Macbook Pro for 1 Million Data insertion
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$start = microtime(true);
$mem_usage = "Memory Usage : " . memory_get_usage() . "\n";
$mem_usage .= "Peak Memory Usage : " . memory_get_peak_usage(). "\n";
$result = true;
while ($result !== false) {
$result = $redis->rpop("test1");
var_dump($result);
}
$mem_usage .= "\nMemory Usage : " . memory_get_usage() . "\n";
$mem_usage .= "Peak Memory Usage : " . memory_get_peak_usage(). "\n";
$duration = microtime(true) - $start;
printf("%s\n\n%0.8f seconds \n", $mem_usage, $duration);
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo PHP_EOL;
$start = microtime(true);
$mem_usage = "Memory Usage : " . memory_get_usage() . "\n";
$mem_usage .= "Peak Memory Usage : " . memory_get_peak_usage(). "\n";
$count = 0;
while($count < 1000000) {
$redis->lpush("test1", $count);
$count++;
echo ' - ' . $count . PHP_EOL;
}
$mem_usage .= "\nMemory Usage : " . memory_get_usage() . "\n";
$mem_usage .= "Peak Memory Usage : " . memory_get_peak_usage(). "\n";
$duration = microtime(true) - $start;
printf("%s\n\n%0.8f seconds \n", $mem_usage, $duration);
Pushing and Poping on Redis For 1 Million Record
Machine information :
> Processor : 3 GHz Intel Core i7
> Memory : 16 GB 1600 MHz DDR3
Only printing datas to screen
-----------------------------
Memory Usage : 272800
Peak Memory Usage : 313168
Memory Usage : 273144
Peak Memory Usage : 313168
3.18391919 seconds
Push to Redis Server (Only Pushing)
--------------------
# For only integer data from 0 to 1000000
Memory Usage : 273184
Peak Memory Usage : 313168
Memory Usage : 281736
Peak Memory Usage : 313168
110.89808011 seconds
Pop From Redis Server (Only Poping)
---------------------
# For only integer data from 0 to 1000000
Memory Usage : 281760
Peak Memory Usage : 287872
Memory Usage : 290312
Peak Memory Usage : 292120
157.16791105 seconds
(Push and Pop at the same time)
-------------------------------
# For only integer data from 0 to 1000000
Memory Usage : 273184
Peak Memory Usage : 313168
Memory Usage : 281736
Peak Memory Usage : 313168
150.26116705 seconds
Pop From Redis Server (Push and Pop at the same time)
---------------------
# For only integer data from 0 to 1000000
Memory Usage : 281848
Peak Memory Usage : 287872
Memory Usage : 290400
Peak Memory Usage : 292208
152.77840209 seconds
Avarege CPU Usage of redis-server Process
-----------------------------------------
> %50 - %60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment