xref: /openbsd-src/gnu/usr.bin/perl/dist/Time-HiRes/t/time.t (revision 56d68f1e19ff848c889ecfa71d3a06340ff64892)
1use strict;
2
3use Test::More tests => 2;
4BEGIN { push @INC, '.' }
5use t::Watchdog;
6
7BEGIN { require_ok "Time::HiRes"; }
8
9SKIP: {
10    skip "no gettimeofday", 1 unless &Time::HiRes::d_gettimeofday;
11    my ($s, $n, $i) = (0);
12    for $i (1 .. 100) {
13        $s += Time::HiRes::time() - CORE::time();
14        $n++;
15    }
16    # $s should be, at worst, equal to $n
17    # (CORE::time() may be rounding down, up, or closest),
18    # but allow 10% of slop.
19    ok abs($s) / $n <= 1.10
20        or print("# Time::HiRes::time() not close to CORE::time()\n");
21    printf("# s = $s, n = $n, s/n = %s\n", abs($s)/$n);
22}
23
241;
25