File: Times.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (39 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (8)
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
use Test2::Bundle::Extended;

use Test2::Util::Times qw/render_bench/;

imported_ok qw{ render_bench };

sub TM() { 0.5 }

is(
    render_bench(0, 2.123456, TM, TM, TM, TM),
    "2.12346s on wallclock (0.50 usr 0.50 sys + 0.50 cusr 0.50 csys = 2.00 CPU)",
    "Got benchmark with < 10 second duration"
);

is(
    render_bench(0, 42.123456, TM, TM, TM, TM),
    "42.1235s on wallclock (0.50 usr 0.50 sys + 0.50 cusr 0.50 csys = 2.00 CPU)",
    "Got benchmark with < 1 minute duration"
);

is(
    render_bench(0, 422.123456, TM, TM, TM, TM),
    "07m:02.12s on wallclock (0.50 usr 0.50 sys + 0.50 cusr 0.50 csys = 2.00 CPU)",
    "Got benchmark with minute+ duration"
);

is(
    render_bench(0, 10422.123456, TM, TM, TM, TM),
    "02h:53m:42.12s on wallclock (0.50 usr 0.50 sys + 0.50 cusr 0.50 csys = 2.00 CPU)",
    "Got benchmark with hour+ duration"
);

is(
    render_bench(0, 501023.123456, TM, TM, TM, TM),
    "05d:19h:10m:23.12s on wallclock (0.50 usr 0.50 sys + 0.50 cusr 0.50 csys = 2.00 CPU)",
    "Got benchmark with day+ duration"
);

done_testing;