Skip to content

Instantly share code, notes, and snippets.

@TobiX
Created May 17, 2022 10:25
Show Gist options
  • Save TobiX/d152d818ab14713e181f1fcfc39bf653 to your computer and use it in GitHub Desktop.
Save TobiX/d152d818ab14713e181f1fcfc39bf653 to your computer and use it in GitHub Desktop.
Quick & dirty bcrypt benchmark
#!/usr/bin/perl
use 5.12.0;
use strict;
use warnings;
use Benchmark ':hireswallclock';
my $time;
my $rounds = 0;
do {
$rounds++;
$time = Benchmark::timeit(1, sub {
crypt('foobar', "\$2b\$$rounds\$01234567890123456789012")
});
say "For $rounds it took ".timestr($time);
} while ($time->real < 30);
@TobiX
Copy link
Author

TobiX commented Apr 23, 2023

Another datapoint, Ryzen 7 3700X (2019):

For 1 it took 2.90871e-05 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 2 it took 4.76837e-06 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 3 it took 5.24521e-06 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 4 it took 1.19209e-06 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 5 it took 5.24521e-06 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 6 it took 8.10623e-06 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 7 it took 3.09944e-06 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 8 it took 4.29153e-06 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 9 it took 3.8147e-06 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
For 10 it took 0.044385 wallclock secs ( 0.04 usr +  0.00 sys =  0.04 CPU) @ 25.00/s (n=1)
For 11 it took 0.088104 wallclock secs ( 0.08 usr +  0.00 sys =  0.08 CPU) @ 12.50/s (n=1)
For 12 it took 0.175497 wallclock secs ( 0.17 usr +  0.00 sys =  0.17 CPU) @  5.88/s (n=1)
For 13 it took 0.352071 wallclock secs ( 0.35 usr +  0.00 sys =  0.35 CPU) @  2.86/s (n=1)
For 14 it took 0.704556 wallclock secs ( 0.70 usr +  0.00 sys =  0.70 CPU) @  1.43/s (n=1)
For 15 it took 1.40713 wallclock secs ( 1.40 usr +  0.00 sys =  1.40 CPU) @  0.71/s (n=1)
For 16 it took 2.8093 wallclock secs ( 2.80 usr +  0.00 sys =  2.80 CPU) @  0.36/s (n=1)
For 17 it took 5.60176 wallclock secs ( 5.60 usr +  0.00 sys =  5.60 CPU) @  0.18/s (n=1)
For 18 it took 11.1452 wallclock secs (11.14 usr +  0.00 sys = 11.14 CPU) @  0.09/s (n=1)
For 19 it took 22.4514 wallclock secs (22.44 usr +  0.00 sys = 22.44 CPU) @  0.04/s (n=1)
For 20 it took 45.6537 wallclock secs (45.64 usr +  0.00 sys = 45.64 CPU) @  0.02/s (n=1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment