The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

Timing HP Calculator Programs
Message #1 Posted by Bill (Smithville, NJ) on 30 Nov 2007, 8:01 a.m.

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.

      
Re: Timing HP Calculator Programs
Message #2 Posted by Giancarlo (Italy) on 30 Nov 2007, 8:38 a.m.,
in response to message #1 by Bill (Smithville, NJ)

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
            
Re: Timing HP Calculator Programs
Message #3 Posted by Massimo Gnerucci (Italy) on 30 Nov 2007, 11:44 a.m.,
in response to message #2 by Giancarlo (Italy)

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.

      
Re: Timing HP Calculator Programs
Message #4 Posted by Egan Ford on 30 Nov 2007, 12:27 p.m.,
in response to message #1 by Bill (Smithville, NJ)

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.

            
Re: Timing HP Calculator Programs
Message #5 Posted by Stefan Vorkoetter on 30 Nov 2007, 2:08 p.m.,
in response to message #4 by Egan Ford

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

                  
Re: Timing HP Calculator Programs
Message #6 Posted by Stefan Vorkoetter on 30 Nov 2007, 2:11 p.m.,
in response to message #5 by Stefan Vorkoetter

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

                        
Re: Timing HP Calculator Programs
Message #7 Posted by Bill (Smithville, NJ) on 30 Nov 2007, 2:44 p.m.,
in response to message #6 by Stefan Vorkoetter

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

                              
Re: Timing HP Calculator Programs
Message #8 Posted by Karl Schneider on 30 Nov 2007, 3:42 p.m.,
in response to message #7 by Bill (Smithville, NJ)

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

                  
Re: Timing HP Calculator Programs
Message #9 Posted by Dave Shaffer (Arizona) on 30 Nov 2007, 3:58 p.m.,
in response to message #5 by Stefan Vorkoetter

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.

            
Re: Timing HP Calculator Programs
Message #10 Posted by Bill (Smithville, NJ) on 30 Nov 2007, 2:48 p.m.,
in response to message #4 by Egan Ford

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

      
Re: Timing HP Calculator Programs
Message #11 Posted by Jeff O. on 30 Nov 2007, 3:39 p.m.,
in response to message #1 by Bill (Smithville, NJ)

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.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall