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.3 by root, Sat Nov 17 01:48:49 2007 UTC vs.
Revision 1.4 by root, Sat Nov 17 01:51:16 2007 UTC

9my @periodic; 9my @periodic;
10 10
11my $base = EV::now; 11my $base = EV::now;
12my $prev = EV::now; 12my $prev = EV::now;
13 13
14for (1..1000) { 14for my $i (1..1000) {
15 my $t = $_ * $_ * 1.735435336; $t -= int $t; 15 my $t = $i * $i * 1.735435336; $t -= int $t;
16 push @timer, EV::timer $t, 0, sub { 16 push @timer, EV::timer $t, 0, sub {
17 my $now = EV::now; 17 my $now = EV::now;
18 18
19 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $now >= $prev\n"; 19 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $i $now >= $prev\n";
20 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $now >= $base + $t\n"; 20 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $i $now >= $base + $t\n";
21 21
22 unless ($id % 3) { 22 unless ($id % 3) {
23 $t *= 0.0625; 23 $t *= 0.0625;
24 $_[0]->set ($t); 24 $_[0]->set ($t);
25 $_[0]->start; 25 $_[0]->start;
27 } 27 }
28 28
29 $prev = $now; 29 $prev = $now;
30 }; 30 };
31 31
32 my $t = $_ * $_ * 1.375475771; $t -= int $t; 32 my $t = $i * $i * 1.375475771; $t -= int $t;
33 push @periodic, EV::periodic $base + $t, 0, 0, sub { 33 push @periodic, EV::periodic $base + $t, 0, 0, sub {
34 my $now = EV::now; 34 my $now = EV::now;
35 35
36 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # p0 $now >= $prev\n"; 36 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # p0 $i $now >= $prev\n";
37 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $now >= $base + $t\n"; 37 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $i $now >= $base + $t\n";
38 38
39 unless ($id % 3) { 39 unless ($id % 3) {
40 $t *= 1.0625; 40 $t *= 1.0625;
41 $_[0]->set ($base + $t); 41 $_[0]->set ($base + $t);
42 $_[0]->start; 42 $_[0]->start;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines