Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!watserv1!70530.1226@compuserve.com
From: Mike Kent <70530.1226@CompuServe.COM>
Subject: Re: Quality of Implementation
Message-ID: <930204092304_70530.1226_DHP24-1@CompuServe.COM>
Sender: root@watserv1.uwaterloo.ca
Organization: University of Waterloo
Date: Thu, 4 Feb 1993 09:23:05 GMT

In article <1993Feb3.020417.2045@csi.jpl.nasa.gov>, sam@csi.jpl.nasa.gov
(Sam Sirlin) proposes

	B3:   +/ iota 15000

as a benchmark for integer additions.  APL systems which support and
exploit arithmetic progression vectors (mainframe APL2, for instance)
will zip through this as they use Gauss's trick to comupte the sum in
constant time for +/ iota (whatever).  A better, or at least more
portable, test would be to assign  15000 ? 15000  to a vector V (and 
have a cup of coffee while the cards are shuffled), and then time

       B3':   +/V

On another issue Sam raises, cost of looping, confidence in timings can
be increased substantially by timing a countdown loop

	K .assign NumberOfIterations+1
      Loop:  .goto (0 < K .assign K-1) / Loop 

and subtracting the (probably small) loop cost from the timing of the
expression+loop.  (Of course everybody knows this, so this is just a
reminder in case someone's forgotten that they know it.)

For the cases you ordinarily really want to optimize, where a few dozen
or a few hundred iterations eats up real time, you don't gain much
precision, but if you have one of those cases where you really are
iterating 10s of thousands of times and want to choose between 
techniques which don't use any measurable time for a few hundred
iterations, it can reveal noticable _relative_ differences in smallish
_absolute_ timings.  As always, your milage may vary.



