ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/t/01_timer.t
Revision: 1.7
Committed: Thu May 22 02:44:57 2008 UTC (16 years, 1 month ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-3_51, rel-3_53, rel-3_52, rel-3_7, rel-3_6, rel-3_49, rel-3_44, rel-3_42, rel-3_43, rel-3_48, rel-3_431
Changes since 1.6: +4 -0 lines
Log Message:
*** empty log message ***

File Contents

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