Last active
December 14, 2015 09:19
-
-
Save dankogai/5064444 to your computer and use it in GitHub Desktop.
Lock file generation benchmark
This file contains 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
#!/usr/bin/env perl | |
use v5.16; | |
use Fcntl qw/:DEFAULT/; | |
use Benchmark qw/:all/; | |
my $tmp_ssd = "$ENV{HOME}/$$"; | |
my $tmp_hdd = "$ENV{HOME}/\@HDD/$$"; | |
sub touch { | |
my $fn = shift; | |
open my $fh, '>', $fn or die "$fn:$!"; | |
print {$fh} $$, "\n"; | |
close $fh; | |
} | |
sub systouch { | |
my $fn = shift; | |
sysopen my $fh, $fn, O_WRONLY|O_CREAT|O_EXCL or die "$fn:$!"; | |
print {$fh} $$, "\n"; | |
close $fh; | |
} | |
cmpthese timethese 0, | |
{ | |
SSD => sub { touch $tmp_ssd; unlink $tmp_ssd }, | |
HDD => sub { touch $tmp_hdd; unlink $tmp_hdd }, | |
SSD_sys => sub { systouch $tmp_ssd; unlink $tmp_ssd }, | |
HDD_sys => sub { systouch $tmp_hdd; unlink $tmp_hdd }, | |
}; | |
unlink $tmp_ssd, $tmp_hdd; | |
__END__ | |
Rate HDD_sys HDD SSD_sys SSD | |
HDD_sys 5676/s -- -1% -8% -13% | |
HDD 5723/s 1% -- -8% -12% | |
SSD_sys 6203/s 9% 8% -- -4% | |
SSD 6489/s 14% 13% 5% -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment