bash has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/evn perl
use strict;
use warnings;
use Benchmark qw(:all :hireswallclock);
use IPC::SysV qw(IPC_CREAT);
use Data::Dumper::Concise;
my $data;
my $size = 65536;
my $id = shmget('12345', $size, IPC_CREAT | 0666);
my $mem = join('', map { ('a' .. 'z')rand(26) } (1..65536));
open(MEMORY, "<", \$mem);
shmwrite( $id, $mem, 0, $size );
cmpthese( -1, {
'shmread' => sub { shmread( $id, $data, 0, $size ) || die "shmread: $!" },
'memory read' => sub { read( MEMORY, $data, $size, 0 ) // die "read: $!" },
});
$ perl bin/test/bench/shmread.pl
Rate shmread memory read
shmread 36202/s -- -100%
memory read 10155128/s 27951% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Slow shared memory issue
by Anonymous Monk on Mar 27, 2016 at 17:00 UTC | |
by bash (Scribe) on Mar 27, 2016 at 19:00 UTC | |
by bash (Scribe) on Mar 27, 2016 at 18:35 UTC |