chiark / gitweb /
found some test utilities re keymap (xkbtest.c 19 Nov 2009) and data age table refres...
[ypp-sc-tools.main.git] / yarrg / test-dataage-refresh-intervals.pl
1 #!/usr/bin/perl
2 $t=0;
3 $intv=10;
4
5 sub roundnum ($) {
6     my ($s) = @_;
7     return
8         $s <    60*2 ? 60 :
9         $s <  3600*2 ? 60 :
10         $s < 86400*2 ? 3600 :
11                        86400;
12 }
13
14 sub conv ($) {
15     my ($s) = @_;
16     return sprintf "%2dd%2dh%02dm%02ds",
17         int($s / 86400), int(($s % 86400) / 3600),
18         int(($s % 3600) / 60), $s % 60;
19 }
20
21 for (;;) {
22     my $unit= roundnum($t);
23     my $r= int($t / $unit) * $unit;
24     printf "%8d %s  +%8d %s  R %8d %s  %7d  %5.2f\n",
25         $t, conv($t), $intv, conv($intv),
26         $r, conv($r), $t-$r, ($t-$r)/$unit;
27     $intv= $t*0.01 + 10;
28     $t += $intv;
29     #$intv *= 1.01;
30     #$intv += 5;
31 }