| 1 | package Benchmark::Dumb::SimpleTime; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use Time::HiRes qw(time); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 8 | 1 | our $DATE = '2023-07-08'; # DATE | |
| 9 | 1 | our $DIST = 'Bencher-Backend'; # DIST | |
| 10 | 1 | our $VERSION = '1.063'; # VERSION | |
| 11 | |||
| 12 | 0 | ▶ | sub _timethese_guts { |
|
Subroutine
_timethese_guts: not called CC=3 SCAR=24.8
| |||
| 13 | 0 | my ($count, $subs, $silent) = @_; | |
| 14 | |||
| 15 | 0 | my $res = {}; | |
| 16 | 0 | for my $name (keys %$subs) { | |
| 17 | 0 | my $sub = $subs->{$name}; | |
| 18 | |||
| 19 | 0 | my $time_start = time(); | |
| 20 | 0 | $sub->() for 1..$count; | |
| 21 | 0 | my $time_end = time(); | |
| 22 | |||
| 23 | 0 | $res->{$name} = bless({ | |
| 24 | name => $name, | ||
| 25 | result => bless({ | ||
| 26 | num => ($time_end - $time_start)/$count, | ||
| 27 | _dbr_nsamples => $count, | ||
| 28 | errors => [undef], | ||
| 29 | }, "Dumbbench::result"), | ||
| 30 | }, "Benchmark::Dumb"); | ||
| 31 | } | ||
| 32 | |||
| 33 | # we are always silent for now | ||
| 34 | 0 | $res; | |
| 35 | } | ||
| 36 | |||
| 37 | 1 | 1; | |
| 38 | # ABSTRACT: Benchmark::Dumb interface for simple time() based benchmarking | ||
| 39 | |||
| 40 | __END__ | ||