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