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
diff --git a/yarrg/test-dataage-refresh-intervals.pl b/yarrg/test-dataage-refresh-intervals.pl
new file mode 100755 (executable)
index 0000000..53e6791
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+$t=0;
+$intv=10;
+
+sub roundnum ($) {
+    my ($s) = @_;
+    return
+        $s <    60*2 ? 60 :
+        $s <  3600*2 ? 60 :
+        $s < 86400*2 ? 3600 :
+                       86400;
+}
+
+sub conv ($) {
+    my ($s) = @_;
+    return sprintf "%2dd%2dh%02dm%02ds",
+        int($s / 86400), int(($s % 86400) / 3600),
+        int(($s % 3600) / 60), $s % 60;
+}
+
+for (;;) {
+    my $unit= roundnum($t);
+    my $r= int($t / $unit) * $unit;
+    printf "%8d %s  +%8d %s  R %8d %s  %7d  %5.2f\n",
+        $t, conv($t), $intv, conv($intv),
+        $r, conv($r), $t-$r, ($t-$r)/$unit;
+    $intv= $t*0.01 + 10;
+    $t += $intv;
+    #$intv *= 1.01;
+    #$intv += 5;
+}