Quiz Summary coming ‘soon’. Until then:
Following are the results I obtained from running my test script against
everyone’s submissions. (I had to fix minor bugs in a few to make them
work.) After that is the (updated) test script.
The script runs a full day of time against the class, advancing the time
uniformly by different numbers of seconds.
For each result, the first line reports whether the class was generally
fast or slow. (The maximum possible variation is 50% fast or slow.)
The second line is the result of recording, each time the fuzzy time
changed, how many minutes ahead or behind the actual time the change
occurred. Ideally, you should see the same percentages spread along the
whole range.
I didn’t test Louis Scoras’ submission, because it took a (good, but)
different track for displaying the time, so I knew it wouldn’t pass any
of my tests.
Loaded suite GavinKistner_1
Started
2 second advance: 3.3% behind, 19.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 1.4% 6.2% 10% 12% 10% 11% 21% 9.7% 17%
6 second advance: 7.0% behind, 11.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0.7% 5.6% 15% 16% 15% 13% 11% 13% 9.7% 2.1%
17 second advance: 11.3% behind, 12.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
2.1% 9.0% 12% 10% 12% 8.3% 13% 11% 7.6% 5.5% 9.0%
30 second advance: 12.8% behind, 12.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
5.5% 13% 13% 7.6% 11% 9.0% 10% 10% 6.9% 9.7% 3.4%
47 second advance: 14.2% behind, 11.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
7.6% 14% 11% 11% 10% 12% 6.2% 10% 5.5% 5.5% 5.5%
60 second advance: 10.7% behind, 16.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
5.6% 9.7% 6.9% 13% 14% 9.0% 6.3% 5.6% 11% 5.6% 13%
65 second advance: 12.1% behind, 16.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
11% 9.0% 12% 7.6% 6.3% 6.9% 6.3% 13% 11% 9.0% 6.9%
120 second advance: 17.1% behind, 11.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 19% 0% 19% 0% 19% 0% 15% 0% 12% 0%
290 second advance: 16.1% behind, 19.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
7.6% 6.9% 6.2% 3.4% 7.6% 5.5% 6.2% 6.2% 6.9% 5.5% 6.2%
=======
BenGiddings_1.rb
<Mon Nov 13 16:53:02 -0700 2006> expected but was
<Mon Nov 13 16:53:00 -0700 2006>.
It is 07:45, the clock displayed “07:3~”,
but it should only display one of [“07:4~”, “07:5~”].
(Last time I asked, it said it was 07:3~.)
=======
Loaded suite CameronPope_1
Started
2 second advance: 0.0% behind, 38.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 0% 0% 0% 0.7% 0% 9.6% 48% 40%
6 second advance: 0.0% behind, 31.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0% 0% 0.7% 12% 32% 36% 18%
17 second advance: 1.4% behind, 19.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 4.1% 2.1% 9.6% 18% 19% 25% 16% 4.1%
30 second advance: 3.9% behind, 14.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 0.7% 7.6% 2.8% 8.3% 14% 22% 17% 13% 8.3% 4.8%
47 second advance: 6.9% behind, 12.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
2.1% 4.1% 6.2% 6.2% 19% 16% 12% 12% 8.9% 9.6% 3.4%
60 second advance: 13.0% behind, 9.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
12% 7.5% 8.2% 10% 15% 12% 14% 8.9% 8.9% 2.7% 0.7%
65 second advance: 11.1% behind, 10.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
11% 4.8% 5.5% 17% 6.9% 19% 11% 10% 7.6% 3.4% 1.4%
120 second advance: 18.5% behind, 10.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 15% 0% 22% 0% 19% 0% 18% 0% 5.6% 0%
290 second advance: 26.5% behind, 11.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
15% 9.6% 6.6% 4.4% 2.9% 3.7% 5.1% 3.7% 4.4% 0% 0%
=======
DamienPetrelli_1
<Thu Nov 09 14:06:28 -0700 2006> expected but was
<Thu Oct 26 01:15:46 -0600 2006>.
It is 02:26, the clock displayed “12:5~”,
but it should only display one of [“02:2~”, “02:3~”].
(Last time I asked, it said it was .)
=======
Loaded suite DanielLucraft_1
Started
2 second advance: 8.1% behind, 16.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 11% 7.6% 9.7% 13% 11% 9.7% 9.7% 9.0% 8.3% 10%
6 second advance: 7.6% behind, 18.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 9.7% 9.7% 8.3% 6.9% 9.0% 12% 8.3% 12% 12% 11%
17 second advance: 9.3% behind, 15.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 12% 11% 9.0% 9.0% 8.3% 14% 9.7% 7.6% 9.0% 9.7%
30 second advance: 7.8% behind, 16.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 8.3% 12% 6.9% 12% 9.0% 12% 10% 9.0% 10% 9.0%
47 second advance: 8.6% behind, 14.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 10% 8.9% 6.2% 12% 14% 10% 10% 7.5% 12% 7.5%
60 second advance: 6.7% behind, 19.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 8.3% 9.0% 7.6% 6.3% 9.0% 11% 14% 10% 13% 12%
65 second advance: 8.8% behind, 16.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 8.3% 12% 12% 12% 11% 7.6% 6.2% 9.0% 6.9% 13%
120 second advance: 6.9% behind, 20.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
10% 0% 16% 0% 18% 0% 21% 0% 23% 0% 11%
290 second advance: 7.0% behind, 16.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
7.3% 9.5% 14% 12% 8.0% 12% 10% 4.4% 7.3% 4.4% 2.9%
=======
Loaded suite JeremyHinegardner_1
Started
2 second advance: 0.0% behind, 42.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 0% 0% 0% 0.7% 20% 78%
6 second advance: 0.0% behind, 38.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 0% 1.4% 9.7% 51% 37%
17 second advance: 0.0% behind, 31.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 2.1% 0.7% 17% 29% 30% 21%
30 second advance: 0.0% behind, 29.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0% 1.4% 8.3% 17% 32% 26% 15%
47 second advance: 0.8% behind, 20.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 5.5% 13% 19% 21% 21% 12% 7.5%
60 second advance: 0.8% behind, 24.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0.7% 0.7% 2.8% 4.1% 7.6% 14% 19% 23% 21% 6.9%
65 second advance: 1.5% behind, 21.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0.7% 1.4% 2.8% 9.7% 9.0% 17% 17% 21% 16% 5.5%
120 second advance: 6.9% behind, 10.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 10% 0% 17% 0% 34% 0% 30% 0% 7.6% 0%
290 second advance: 8.4% behind, 13.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
9.2% 11% 12% 11% 13% 11% 7.7% 6.3% 7.0% 4.2% 0%
=======
Loaded suite MarcelWard_1
Started
2 second advance: 7.2% behind, 17.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 6.2% 6.8% 8.2% 7.5% 11% 4.1% 17% 14% 14% 11%
6 second advance: 5.4% behind, 18.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 4.2% 4.9% 6.9% 7.6% 10% 12% 16% 15% 9.0% 14%
17 second advance: 8.1% behind, 15.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 8.2% 6.2% 4.8% 11% 16% 12% 8.2% 14% 10% 9.6%
30 second advance: 7.2% behind, 13.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 6.9% 5.5% 7.6% 14% 11% 12% 18% 9.0% 10% 4.1%
47 second advance: 7.5% behind, 16.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 6.2% 9.0% 7.6% 12% 10% 9.0% 15% 12% 12% 6.2%
60 second advance: 10.6% behind, 13.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
4.1% 10% 9.7% 9.0% 13% 8.3% 12% 12% 7.6% 9.7% 4.1%
65 second advance: 7.7% behind, 17.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
4.8% 4.8% 9.7% 7.6% 6.9% 9.0% 9.7% 13% 16% 12% 6.2%
120 second advance: 6.4% behind, 14.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
14% 0% 14% 0% 29% 0% 26% 0% 17% 0% 1.4%
290 second advance: 10.1% behind, 16.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
8.4% 9.8% 9.8% 12% 7.7% 9.1% 10% 10% 4.2% 4.9% 0.7%
=======
Loaded suite PaoloNegri_1
Started
2 second advance: 7.8% behind, 9.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 5.5% 8.3% 8.3% 17% 17% 18% 10% 10% 5.5% 0.7%
6 second advance: 7.0% behind, 11.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 2.8% 6.2% 10% 12% 17% 12% 19% 9.0% 9.0% 3.4%
17 second advance: 8.1% behind, 10.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 2.8% 10% 8.3% 14% 17% 14% 14% 6.9% 8.3% 2.8%
30 second advance: 8.9% behind, 9.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 7.6% 9.0% 11% 14% 14% 18% 10% 8.3% 5.5% 2.1%
47 second advance: 10.2% behind, 10.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 10% 8.3% 9.7% 14% 17% 9.7% 15% 5.5% 6.9% 3.4%
60 second advance: 8.3% behind, 11.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 6.2% 12% 13% 11% 11% 16% 16% 8.3% 4.1% 1.4%
65 second advance: 8.6% behind, 10.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
4.8% 5.5% 4.8% 11% 16% 19% 13% 5.5% 12% 4.1% 2.8%
120 second advance: 6.3% behind, 11.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 8.3% 0% 22% 0% 35% 0% 20% 0% 14% 0%
290 second advance: 9.1% behind, 13.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
6.2% 9.0% 11% 10% 14% 11% 9.7% 9.0% 3.4% 2.8% 0.7%
=======
Loaded suite RobertConn_1
Started
2 second advance: 0.0% behind, 49.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 0% 0% 0% 0% 0% 0% 0% 99%
6 second advance: 0.0% behind, 48.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 0% 0% 0% 0% 99%
17 second advance: 0.0% behind, 46.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 0% 0% 0.7% 9.0% 90%
30 second advance: 0.0% behind, 45.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0% 0% 0% 1.4% 5.5% 18% 74%
47 second advance: 0.0% behind, 42.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 2.1% 2.1% 2.8% 10% 23% 59%
60 second advance: 0.1% behind, 42.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 1.4% 0.7% 6.9% 12% 22% 57%
65 second advance: 0.1% behind, 41.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 2.7% 2.7% 8.9% 13% 20% 51%
120 second advance: 3.6% behind, 27.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 2.1% 0% 9.0% 0% 7.6% 0% 21% 0% 59% 0%
290 second advance: 10.4% behind, 29.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
2.3% 5.5% 3.1% 4.7% 3.1% 5.5% 12% 16% 13% 14% 9.4%
=======
Loaded suite ThomasMueller_1
Started
2 second advance: 0.0% behind, 43.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0% 0% 0% 1.4% 21% 77%
6 second advance: 0.0% behind, 38.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0% 0% 0% 0.7% 8.3% 46% 44%
17 second advance: 0.1% behind, 28.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 4.1% 21% 37% 23% 13%
30 second advance: 0.4% behind, 25.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 1.4% 0% 1.4% 3.4% 10% 24% 30% 19% 10%
47 second advance: 0.8% behind, 21.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 0.7% 5.5% 9.0% 19% 19% 20% 16% 9.7%
60 second advance: 1.8% behind, 17.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0.7% 1.4% 4.1% 9.7% 15% 19% 17% 23% 9.0% 1.4%
65 second advance: 1.9% behind, 21.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 4.9% 6.9% 12% 17% 15% 20% 18% 5.6%
120 second advance: 1.7% behind, 19.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 0% 8.9% 0% 29% 0% 33% 0% 21% 0% 6.2%
290 second advance: 10.4% behind, 12.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
11% 14% 12% 9.3% 11% 9.3% 7.9% 5.7% 5.7% 2.9% 0.7%
=======
Loaded suite TomPollard_1
Started
2 second advance: 0.0% behind, 46.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 0% 0% 0% 0% 5.5% 94%
6 second advance: 0.0% behind, 42.7% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 0% 0% 2.7% 35% 61%
17 second advance: 0.0% behind, 35.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0.7% 3.5% 6.3% 19% 38% 33%
30 second advance: 0.1% behind, 29.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0.7% 0.7% 4.8% 6.2% 22% 21% 25% 19%
47 second advance: 0.4% behind, 24.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 1.4% 3.4% 6.8% 16% 20% 18% 25% 7.5%
60 second advance: 1.5% behind, 23.5% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 2.1% 0% 2.1% 4.8% 14% 12% 14% 20% 21% 9.7%
65 second advance: 1.1% behind, 22.0% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0.7% 0% 0.7% 0.7% 6.9% 14% 16% 21% 19% 14% 7.6%
120 second advance: 5.0% behind, 13.1% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 6.2% 0% 17% 0% 34% 0% 25% 0% 18% 0%
290 second advance: 7.4% behind, 16.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
8.0% 12% 11% 11% 12% 10% 10% 7.2% 5.8% 3.6% 0.7%
=======
Loaded suite TomPollard_2
Started
2 second advance: 0.0% behind, 49.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0% 0% 0% 0.7% 0% 0% 99%
6 second advance: 0.0% behind, 48.8% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0.7% 0% 0% 0% 0% 0% 0% 0.7% 99%
17 second advance: 0.0% behind, 46.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 0% 0% 0% 2.1% 15% 82%
30 second advance: 0.0% behind, 40.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 0% 0% 0% 0.7% 0.7% 3.4% 3.4% 14% 24% 53%
47 second advance: 5.0% behind, 22.2% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
2.8% 4.1% 4.1% 6.9% 8.3% 9.0% 9.7% 10% 12% 16% 16%
60 second advance: 7.7% behind, 19.6% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
8.3% 3.5% 6.9% 5.6% 7.6% 12% 9.7% 13% 8.3% 8.3% 17%
65 second advance: 15.3% behind, 11.3% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
12% 9.7% 15% 12% 14% 6.2% 8.3% 6.9% 4.8% 4.1% 4.8%
120 second advance: 7.6% behind, 16.9% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
0% 12% 0% 11% 0% 18% 0% 33% 0% 22% 0%
290 second advance: 15.1% behind, 16.4% ahead
-5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5
12% 12% 9.7% 7.6% 2.8% 5.5% 6.9% 7.6% 4.1% 5.5% 2.8%
=======
The test script follows. Each file was run using:
ruby -rtest_fuzzy.rb
require ‘test/unit’
$DEBUG = false
class Time
def to_fuzzy
s = strftime("%H:%M")
s[4] = “~”
s
end
def short
strftime("%H:%M")
end
def round_to( seconds )
seconds = seconds.round
Time.at( self.to_i / seconds * seconds )
end
end
RUNS_PER_SET = 1
class FuzzyTimeTester < Test::Unit::TestCase
def test_running
[ 2, 6, 17, 30, 47, 60, 65, 120, 290 ].each{ |advance_seconds|
runs, num_ahead, num_behind = 0, 0, 0
offsets = Hash.new(0)
RUNS_PER_SET.times{
t = Time.at( Time.new + rand( 3600 * 300 ) )
end_time = t + 60 * 60 * 24 # Run for 24 hours
ft = FuzzyTime.new( t )
last_value = nil
while( t < end_time )
assert_equal t, ft.actual
t0 = Time.at( t - 60 * 5 )
t2 = Time.at( t + 60 * 5 )
legal_values = [ t0, t, t2 ].map{ |x| x.to_fuzzy }.uniq
fuzzy_fuzz = ft.to_s
if last_value
y,mon,day = t.year, t.mon, t.day
h,m = last_value.scan(/\d+/).map{ |s| s.to_i }
m *= 10
if (m -= 10) < 0
m %= 60
if (h -= 1) < 0
h %= 24
end
end
illegal_old_value = Time.local( y,mon,day,h,m ).to_fuzzy
legal_values -= [ illegal_old_value ]
if $DEBUG
puts "Now: %s=>%s; legal: %s (was %s, can't be %s)" % [
t.short, fuzzy_fuzz,
legal_values.inspect, last_value,
illegal_old_value
]
end
end
assert_block( ( "It is %s, the clock displayed %s,\n" +
"but it should only display one of %s.\n" +
"(Last time I asked, it said it was %s.)" ) % [
t.short, fuzzy_fuzz.inspect,
legal_values.inspect,
last_value
] ){
legal_values.include?( fuzzy_fuzz )
}
actual_fuzz = t.to_fuzzy
ahour, amin = actual_fuzz.scan( /\d+/ ).map{ |x| x.to_i }
fhour, fmin = fuzzy_fuzz.scan( /\d+/ ).map{ |x| x.to_i }
if fuzzy_fuzz != actual_fuzz
if fmin>amin || fhour>ahour || ( fhour==0 && ahour==23 )
num_ahead += 1
else
num_behind +=1
end
end
if fuzzy_fuzz != last_value
ahour2, amin2 = t.short.scan( /\d+/ ).map{ |x| x.to_i }
if fmin>amin || fhour>ahour || ( fhour==0 && ahour==23 )
offset = ( fmin*10 - amin2 ) % 60
else
offset = ( fmin*10 - amin2 )
end
offsets[ offset ] += 1
if $DEBUG
puts ( "It is %s, I just switched from %s to %s, " +
"and I think that's an offset of %+d" ) % [
t.short, last_value, fuzzy_fuzz, offset
]
end
end
runs += 1
last_value = fuzzy_fuzz
ft.advance( advance_seconds )
t += advance_seconds
end
}
puts "%d second advance: %.1f%% behind, %.1f%% ahead" % [
advance_seconds,
100.0 * num_behind / runs,
100.0 * num_ahead / runs
]
total_offsets = offsets.inject(0){ |sum,kv| sum+kv[1] }
-5.upto(5){ |o|
print "#{o>0?'+':''}#{o}".center( 5 )
}; print "\n"
-5.upto(5){ |o|
pct = 100.0 * offsets[o] / total_offsets
print( ( "%.#{(pct<10&&pct>0)?1:0}f%" % pct ).center( 5 ) )
}; puts "\n "
}
end
end