ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/t/01_timer.t
(Generate patch)

Comparing EV/t/01_timer.t (file contents):
Revision 1.5 by root, Sat Nov 17 01:52:50 2007 UTC vs.
Revision 1.6 by root, Thu Nov 22 04:52:24 2007 UTC

2 2
3no warnings; 3no warnings;
4use strict; 4use strict;
5 5
6use EV; 6use EV;
7
8my $fudge = 0.02; # allow rt and monotonic clock to disagree by this much
7 9
8my $id = 1; 10my $id = 1;
9my @timer; 11my @timer;
10my @periodic; 12my @periodic;
11 13
15for my $i (1..1000) { 17for my $i (1..1000) {
16 my $t = $i * $i * 1.735435336; $t -= int $t; 18 my $t = $i * $i * 1.735435336; $t -= int $t;
17 push @timer, EV::timer $t, 0, sub { 19 push @timer, EV::timer $t, 0, sub {
18 my $now = EV::now; 20 my $now = EV::now;
19 21
20 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $i $now >= $prev\n"; 22 print $now + $fudge >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $i $now + $fudge >= $prev\n";
21 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $i $now >= $base + $t\n"; 23 print $now + $fudge >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $i $now + $fudge >= $base + $t\n";
22 24
23 unless ($id % 3) { 25 unless ($id % 3) {
24 $t *= 0.0625; 26 $t *= 0.0625;
25 $_[0]->set ($t); 27 $_[0]->set ($t);
26 $_[0]->start; 28 $_[0]->start;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines