On Sat, Sep 08, 2001 at 04:24:46PM -0400, Mark-Jason Dominus wrote:
> > Memoize's speed test is giving us some trouble now that we're running
> > it a few dozen times a day, each.  It looks like it's just an
> > intermittent failure because it depends on real time.  Perhaps if it
> > used times() instead?
> 
> Yes, I'll try to see what I can do about it.
> 
> Sorry for the inconvenience.


This should do it.  It should now be possible to just suspend the test
randomly and run whatever other processes you want and still have it
work.


--- lib/Memoize/t/speed.t       2001/09/08 20:21:56     1.1
+++ lib/Memoize/t/speed.t       2001/09/08 21:02:22
@@ -12,6 +12,13 @@
 # If we don't say anything, maybe nobody will notice.
 # print STDERR "\nWarning: I'm testing the speedup.  This might take up to thirty 
seconds.\n                    ";
 
+# XXX I don't know what $^O is for RISC OS!
+$Is_RISC_OS = 0;
+
+# perlport says times() is "Not useful" on RISC OS.  For everything else
+# it should be servicable for our purposes.
+*my_time = $Is_RISC_OS ? sub { time }
+                       : sub { (times)[0] };
 
 print "1..6\n";
 
@@ -47,10 +54,10 @@
 my $LONG_RUN = 10;
 
 while (1) {
-  my $start = time;
+  my($start) = my_time();
   $COUNT=0;
   $RESULT = fib($N);
-  $ELAPSED = time - $start;
+  $ELAPSED = my_time() - $start;
   last if $ELAPSED >= $LONG_RUN;
   if ($ELAPSED > 1) {
       print "# fib($N) took $ELAPSED seconds.\n" if $N % 1 == 0;
@@ -73,9 +80,9 @@
 &memoize('fib');
 
 $COUNT=0;
-$start = time;
+$start = my_time();
 $RESULT2 = fib($N);
-$ELAPSED2 = time - $start + .001; # prevent division by 0 errors
+$ELAPSED2 = my_time() - $start + .001; # prevent division by 0 errors
 
 print (($RESULT == $RESULT2) ? "ok 1\n" : "not ok 1\n");
 # If it's not ten times as fast, something is seriously wrong.
@@ -85,9 +92,9 @@
 
 # Do it again. Should be even faster this time.
 $COUNT = 0;
-$start = time;
+$start = my_time();
 $RESULT2 = fib($N);
-$ELAPSED2 = time - $start + .001; # prevent division by 0 errors
+$ELAPSED2 = my_time() - $start + .001; # prevent division by 0 errors
 
 print (($RESULT == $RESULT2) ? "ok 4\n" : "not ok 4\n");
 print (($ELAPSED/$ELAPSED2 > 10) ? "ok 5\n" : "not ok 5\n");


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <[EMAIL PROTECTED]>       Kwalitee Is Job One
local $variable for local @people;

Reply via email to