ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/t/01_timer.t
Revision: 1.6
Committed: Thu Nov 22 04:52:24 2007 UTC (16 years, 7 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-2_01, rel-2_0, rel-3_31, rel-3_33, rel-1_71, rel-3_4, rel-3_3, rel-3_2, rel-3_1, rel-3_0, rel-1_85, rel-1_8, rel-1_72, rel-1_3, rel-1_2, rel-1_5, rel-1_4, rel-1_6, rel-3_41, rel-1_81, rel-1_86
Changes since 1.5: +4 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.3 BEGIN { $| = 1; print "1..6002\n"; }
2    
3     no warnings;
4 root 1.5 use strict;
5 root 1.1
6     use EV;
7    
8 root 1.6 my $fudge = 0.02; # allow rt and monotonic clock to disagree by this much
9    
10 root 1.1 my $id = 1;
11     my @timer;
12 root 1.3 my @periodic;
13 root 1.1
14     my $base = EV::now;
15     my $prev = EV::now;
16    
17 root 1.4 for my $i (1..1000) {
18     my $t = $i * $i * 1.735435336; $t -= int $t;
19 root 1.1 push @timer, EV::timer $t, 0, sub {
20 root 1.3 my $now = EV::now;
21    
22 root 1.6 print $now + $fudge >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $i $now + $fudge >= $prev\n";
23     print $now + $fudge >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $i $now + $fudge >= $base + $t\n";
24 root 1.3
25     unless ($id % 3) {
26     $t *= 0.0625;
27     $_[0]->set ($t);
28     $_[0]->start;
29     $t = $now + $t - $base;
30     }
31    
32     $prev = $now;
33     };
34 root 1.2
35 root 1.4 my $t = $i * $i * 1.375475771; $t -= int $t;
36 root 1.3 push @periodic, EV::periodic $base + $t, 0, 0, sub {
37     my $now = EV::now;
38    
39 root 1.4 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # p0 $i $now >= $prev\n";
40     print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $i $now >= $base + $t\n";
41 root 1.1
42     unless ($id % 3) {
43     $t *= 1.0625;
44 root 1.3 $_[0]->set ($base + $t);
45 root 1.1 $_[0]->start;
46     }
47 root 1.3
48     $prev = $now;
49 root 1.1 };
50     }
51    
52     print "ok 1\n";
53     EV::loop;
54 root 1.3 print "ok 6002\n";
55 root 1.1