Created
December 2, 2019 13:04
-
-
Save renatocron/e9228433ab6706230324dde86224c344 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
use strict; | |
use warnings; | |
use Benchmark qw/timethese cmpthese :hireswallclock/; | |
use Redis; | |
use Redis::hiredis; | |
my $r2 = Redis->new; | |
my $r = Redis::hiredis->new(); | |
$r->connect( '127.0.0.1', 6379 ); | |
my $result = timethese( | |
-2, | |
{ | |
'-e' => sub { | |
$x++ if -e '/tmp/' . $$; | |
}, | |
'-dev' => sub { | |
$x++ if -e '/dev/shm/' . $$; | |
}, | |
'redis' => sub { | |
$r2->get($$); | |
}, | |
'hredis' => sub { | |
$r->command("get", $$); | |
} | |
} | |
); | |
cmpthese($result); | |
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
Benchmark: running -dev, -e, hredis, redis for at least 2 CPU seconds... | |
-dev: 2.1023 wallclock secs ( 0.94 usr + 1.16 sys = 2.10 CPU) @ 882212.38/s (n=1852646) | |
-e: 2.0493 wallclock secs ( 1.31 usr + 0.74 sys = 2.05 CPU) @ 1450432.20/s (n=2973386) | |
hredis: 3.18629 wallclock secs ( 1.01 usr + 1.08 sys = 2.09 CPU) @ 102889.95/s (n=215040) | |
redis: 2.11608 wallclock secs ( 1.49 usr + 0.59 sys = 2.08 CPU) @ 36428.37/s (n=75771) | |
Rate redis hredis -dev -e | |
redis 36428/s -- -65% -96% -97% | |
hredis 102890/s 182% -- -88% -93% | |
-dev 882212/s 2322% 757% -- -39% | |
-e 1450432/s 3882% 1310% 64% -- | |
- | |
redis vs file exists |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment