ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/t/01_timer.t
Revision: 1.5
Committed: Sat Nov 17 01:52:50 2007 UTC (16 years, 7 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_1
Changes since 1.4: +1 -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 $id = 1;
9 my @timer;
10 my @periodic;
11
12 my $base = EV::now;
13 my $prev = EV::now;
14
15 for my $i (1..1000) {
16 my $t = $i * $i * 1.735435336; $t -= int $t;
17 push @timer, EV::timer $t, 0, sub {
18 my $now = EV::now;
19
20 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $i $now >= $prev\n";
21 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $i $now >= $base + $t\n";
22
23 unless ($id % 3) {
24 $t *= 0.0625;
25 $_[0]->set ($t);
26 $_[0]->start;
27 $t = $now + $t - $base;
28 }
29
30 $prev = $now;
31 };
32
33 my $t = $i * $i * 1.375475771; $t -= int $t;
34 push @periodic, EV::periodic $base + $t, 0, 0, sub {
35 my $now = EV::now;
36
37 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # p0 $i $now >= $prev\n";
38 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $i $now >= $base + $t\n";
39
40 unless ($id % 3) {
41 $t *= 1.0625;
42 $_[0]->set ($base + $t);
43 $_[0]->start;
44 }
45
46 $prev = $now;
47 };
48 }
49
50 print "ok 1\n";
51 EV::loop;
52 print "ok 6002\n";
53