File: 04_reports.t

package info (click to toggle)
libbenchmark-timer-perl 0.7112-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 312 kB
  • sloc: perl: 2,679; makefile: 8
file content (73 lines) | stat: -rwxr-xr-x 1,416 bytes parent folder | download | duplicates (6)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use strict;
use Test::More tests => 10;
use Benchmark::Timer;

# ------------------------------------------------------------------------
# Basic tests of the Benchmark::Timer library.

my $t = Benchmark::Timer->new;

my ($report, %reports);

$t->start('tag1');
$t->stop;

#1
ok(1, 'Start/stop a tag');

$report = $t->report;

#2
like($report, qr/^1 trial of tag1 \(.* total\)\n$/,
  'Single timing report');

$t->start('tag1');
$t->stop;

$report = $t->report;

#3
like($report, qr/^2 trials of tag1 \(.* total\), .*\/trial\n$/,
  'Multiple timing report');

$report = $t->reports;

#4
like($report, qr/^2 trials of tag1 \(.* total\), .*\/trial\n$/,
  'Multiple timing report--scalar');

%reports = $t->reports;

#4
is(scalar keys %reports, 1,
  'Multiple timing report--hash');

$t->start('tag2');
$t->stop;

$report = $t->report;

#6
like($report, qr/^1 trial of tag2 \(.* total\)\n$/,
  'Single timing report--last tag used');

$report = $t->reports;

#7
like($report, qr/^2 trials of tag1 \(.* total\), .*\/trial\n1 trial of tag2 \(.* total\)\n$/,
  'Multiple timing report--scalar');

%reports = $t->reports;

#8
is(scalar keys %reports, 2,
  'Multiple timing report--hash');

#9
like($reports{'tag1'}, qr/^2 trials of tag1 \(.* total\), .*\/trial\n$/,
  'Multiple timing report--hash element 1');

#10
like($reports{'tag2'}, qr/^1 trial of tag2 \(.* total\)\n$/,
  'Multiple timing report--hash element 2');