add benchmark
This commit is contained in:
parent
95fc42626a
commit
4155d8ca70
38
2023/01/benchmark.pl
Normal file
38
2023/01/benchmark.pl
Normal file
@ -0,0 +1,38 @@
|
||||
use 5.38.0;
|
||||
|
||||
use Benchmark ':hireswallclock';
|
||||
use Path::Tiny;
|
||||
use JSON qw/ to_json /;
|
||||
use DateTime;
|
||||
|
||||
use Part1;
|
||||
use Part2;
|
||||
|
||||
my @parts = (
|
||||
{ part => 1, sub => \&Part1::solution_1, expected => 56397 },
|
||||
{ part => 2, sub => \&Part2::solution_2, expected => 55701 },
|
||||
);
|
||||
|
||||
my $input = path('./input')->slurp;
|
||||
|
||||
for my $part (@parts) {
|
||||
my $res = Benchmark::countit(
|
||||
10,
|
||||
sub {
|
||||
$part->{sub}->($input) == $part->{expected} or die;
|
||||
}
|
||||
);
|
||||
|
||||
my $result = {
|
||||
day => 1,
|
||||
year => 2023,
|
||||
|
||||
#variant => '',
|
||||
language => 'perl',
|
||||
part => $part->{part},
|
||||
time => $res->cpu_a / $res->iters,
|
||||
timestamp => DateTime->now->iso8601,
|
||||
};
|
||||
say to_json $result;
|
||||
}
|
||||
|
2
2023/benchmark.json
Normal file
2
2023/benchmark.json
Normal file
@ -0,0 +1,2 @@
|
||||
{"language":"perl","time":0.00189813978688821,"part":1,"day":1,"year":2023,"timestamp":"2023-12-01T17:35:46"}
|
||||
{"language":"perl","part":2,"time":0.00721379310344828,"day":1,"year":2023,"timestamp":"2023-12-01T17:35:58"}
|
Loading…
Reference in New Issue
Block a user