Timing HP Calculator Programs



#12

Previous post by Jeff O. gave some timings for the HP35S Programming Contest in HHC 2007. What caught my attention was that Jeff gave the timings to 100th of a second. See following thread:

My entry for the HP35S Programming Contest in HHC 2007 (long)

This got me thinking about how to take a timing of a program's execution. I have been starting a stop watch when I press Enter and then watch the disply for final answer and stopping the stop watch. Depending on my reflexes and eye/hand coordination, I would guess the accuracy would be within a half second or so.

Is there any way to take a more accurate reading and eliminate the human factor? Some sort of mechanical device that pushes the key, starts timing and then somehow watches the display to know when to shut off is obviously not a solution.

I finally came up with one possible solution - If the calculator has a Beep command, then insert Beep at start and another Beep at end. A fairly simple mike pickup into a PC soundcard and program to start/stop timer. This should give consistant, repeatable timings to fairly high degree of accuracy.

Unfortuately, unless I have overlooked it, the HP-35S does not have a Beep Command.

Are there any other ways to automate timing of a program?

Bill


Edited: 30 Nov 2007, 8:04 a.m.


#13

Hi Bill.

The 50G (and, I guess, other HP calcs as well..) provide the TICKS command, that, as the Advanced User's Reference Manual says:

Quote:
[...]Returns the system time as a binary integer, in units of 1/8192 second[...]



and:

Quote:
[...]If the result from a previous invocation from TICKS is on level 1 of the stack, then the
command: TICKS SWAP - B->R 8192 /
returns a real number whose value is the elapsed time in seconds between the two invocations[...]



Thus I guess that using the above command as the very first and the very last in a program will allow you to time fairly precisely the elapsed time.

Hope this helps.

Best regards.

Giancarlo

#14

Hi Giancarlo,
there's the TEVAL command too...

But on the 35S? I don't have one yet, and manuals are not available, alas.

Greetings,
Massimo

Edited: 30 Nov 2007, 11:45 a.m.

#15

The only timer the 35s has is the timeout timer. I like the beep idea, but there is no beep. Other calcs (71/41/48/49/50) have clocks and are easy to time.

One way to increase your accuracy with a stop watch is to not start the benchmark and the stopwatch in parallel. Use a mental metronome, start the benchmark, wait a sec, start stopwatch, wait for results, after you see them wait a sec, stop stopwatch. This will give you more time to react.

Other suggestions:

Run in a loop 100 times, time manually, then /100 the time. If your timing is off 1 sec, then its really only 1/100 off. Accurate but not automated.

For long programs, 10 times is good enough. In any case run once, time manually, *(nruns * .95) to get ETA, set alarm on your watch (or 41CX, 50g, etc...), go back to work, look at calc when alarm goes off.

For very long programs 1 time is good enough, you may need to time a subset of the problem to get an ETA. Or, write a 2nd program that runs for ~60 sec (you will need to time it to get better est.). Then after your program runs, run the 2nd program in a loop, increment a counter, make sure the program has a pause with message at the start or end, press cancel when message appears, stop stopwatch, time = totaltime - counter*60. Nice solution if your program completes when you are away from your desk.

If you have an emulator you can screen shot the results, then start the run continuously getting images, if a match to results, stop timer. I've done this with Linux/Nonpareil. If you want to do this with a physical device you'll need a web cam and some smart software.


Edited: 30 Nov 2007, 12:34 p.m.


#16

You can also use a camcorder to watch the calculator. Later, review the recording to determine the time that you started the calculation and the time that it finished. If you can transfer the video to a computer, it's even better, since you can look at it with a video editing tool to find the exact frames where it started or finished. This should give you times to about 1/30th of a second (1/25th in Europe).

Another possibility, which I haven't tried, but might be worth investigating, is to monitor the power consumption of the calculator. Presumably it uses more power when running a program than when it's stopped. Of course this requires a modification to the calculator.

Stefan


#17

Responding to my own message :-)

When I was a kid, I noticed that my Commodore programmable calculator would cause tones in an AM pocket radio held next to it. These tones would change in character when a program was running. I wonder if the same is true of the 35s? I'll have to try it. If this works, it may be possible to build a simple circuit that starts and stops a timer based on what's coming out of the radio's earphone jack.

Stefan


#18

Hi Stefan,

Quote:
Commodore programmable calculator would cause tones in an AM pocket radio

Now that you mentioned it, I think some people actually wrote some programs on early HP or TI that would play (sort of) songs on an AM radio. I know it was done with some of the early computers.

I just tried it with a HP-35S - couldn't detect any change in radio noise. If I knew what frequency the 35S operated at, then I could probally tune the radio to either that frequence or the offset of that frequency to the radio's IF frequency and maybe pick it up.

Bill


#19

Hi, Stefan and Bill ---

I'd suspect that those devices of the 1970's were developed prior to FCC regulations concerning radio interference. I wonder how significant the EMF emissions of the (unshielded?) power-hungry LED's were.

See, for example, p. A-12 of the HP-35s manual. Similar verbiage is present in the HP-10C manual (but not in the HP-34C manual), so this requirement goes back to at least the early 1980's.

-- KS

#20

Quote:
You can also use a camcorder to watch the calculator. Later, review the recording to determine the time that you started the calculation and the time that it finished. If you can transfer the video to a computer, it's even better, since you can look at it with a video editing tool to find the exact frames where it started or finished. This should give you times to about 1/30th of a second (1/25th in Europe).

If you have a digital display kitchen (or some other kind of) timer or stopwatch (you can buy them list price for less than $10 and probably find one at a garage sale for 50 cents), you could include it in the camcorder field of view.

#21

Hi Egan,

Thanks for your nice response. I agree that for most purposes, an accuracy of 1 second or so is adequate. It's just when I saw someone posting times to the 100th of a second that got me thinking about it.

For any of the calculators that have timers built-in (HP-48/49/50), timing is very easy. I still like the idea of using the Beep - would work fairly easy on the HP-41 and HP-42s.

Bill

#22

I performed the timing tests exactly as you described: I pressed ENTER on the calculator and the start button on a stopwatch at as close to the same time as I can make my left hand and right hand do something, then watched the display and pressed the stop button as soon as the calculator stopped running. As such, the times given are the program run time plus any timing difference in starting the calculator and the watch plus my reaction time in stopping the watch at the end. (I assume that this is the method Gene used at the HHC to time the programs.) If I insert a stop instruction in the program between the part that counts the occurrences of each digit and the part that rebuilds the sorted number, then time the two parts separately, the sum of those times exceeds the time to run the whole program by an average of 0.38 second. The only difference between the two methods should be the need to stop and start the program twice with the stop instruction vs. once without it, so that should be equal to the total of the starting time error plus reaction time to stop.

A more accurate timing method to eliminate the above problem would be very desirable.


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime: Lists in programs Alberto Candel 7 1,235 12-04-2013, 02:16 AM
Last Post: Alberto Candel
  HP Prime: matrices in programs, in need of help Alberto Candel 9 1,070 11-26-2013, 01:33 AM
Last Post: cyrille de Brébisson
  Grouping programs on the HP Prime Michael de Estrada 11 1,314 11-04-2013, 01:38 PM
Last Post: Damien
  Transfering HP-85A Programs Gerry Schultz 5 898 10-17-2013, 12:30 PM
Last Post: Philip Reagan (Texas)
  How do I upload to programs to HP 39GII ? Bernd Grubert 1 469 03-01-2013, 05:20 AM
Last Post: Bernd Grubert
  Programs for HP-48S William N Strew 4 569 07-13-2012, 07:17 PM
Last Post: Eddie W. Shore
  wp34S timing crystal Peter Mansvelder 30 2,339 01-24-2012, 03:49 AM
Last Post: Bart (UK)
  HP 15c LE Display timing issues? Michael Kussmaul 5 629 10-02-2011, 12:07 PM
Last Post: Michael Kussmaul
  34s: Anyone have an instruction timing table? Gene Wright 15 1,288 07-19-2011, 11:28 PM
Last Post: Paul Dale
  A few simple HP 35s programs Lode 3 477 07-04-2011, 05:38 PM
Last Post: Paul Dale

Forum Jump: