File: digest-bench

package info (click to toggle)
libdigest-perl 1.17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 108 kB
  • ctags: 18
  • sloc: perl: 293; makefile: 2
file content (28 lines) | stat: -rwxr-xr-x 535 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl -w

use strict;
die unless @ARGV;

my($mod, @args) = @ARGV;

eval "require $mod"; die $@ if $@;

$a = substr(join("", "a" .. "z",) x 800, 0, 8 * 1024);
my $count = 4*1024;

use Time::HiRes qw(time);

my $before = time;
my $ctx = $mod->new(@args);
for (1 .. $count) {
    $ctx->add($a);
}
print $ctx->hexdigest, "\n";

my $sec = time - $before;
my $bytes = length($a) * $count;

print "$bytes/$sec\n";

my $vers = do { no strict 'refs'; ${$mod . '::VERSION'} };
printf "$mod $vers\t%.2f MB/s\n", $bytes/(1024*1024*$sec)