Post Reply 
HP Prime vs HP71 benchmark
01-20-2017, 08:35 PM
Post: #1
HP Prime vs HP71 benchmark
I finished my random Pi program and compared the Prime and HP71.

Here is the prime program:
Code:

EXPORT PITWO()
BEGIN
H:=0;
T:=0;
RANDSEED(1);
S:=Ticks;
WHILE 1 DO
T:=T+1;
X:=RANDOM()^2+RANDOM()^2;
IF X<= 1 THEN
H:=H+1;
END;

IF T MOD 10000 = 0 THEN
E:= TICKS-S;
PRINT("T:"+T+" PI:"+4*H/T+" E:"+E);
END;
END;
END;

Basically you generate two random numbers and see if it is within the radius of a circle. The ratio of the number of points inside the circle and all the points is pi/4.

For 50,000 pairs:
HP71: Pi=3.14592; Time: 8370 seconds
Prime: Pi=3.14592; Time 8.732 seconds

The prime was 960 times faster than the HP71, which I guess is not really a surprise, given the clock ratio is about 640. (Unlike the HP71, I cannot get an exact clock speed for my prime - no peek() function). The calculations appear to be identical - even to the random numbers generated.
Find all posts by this user
Quote this message in a reply
01-20-2017, 10:35 PM
Post: #2
RE: HP Prime vs HP71 benchmark
(01-20-2017 08:35 PM)KeithB Wrote:  I finished my random Pi program and compared the Prime and HP71.

Here is the prime program:
Hi, very interesting ... would you show us the program of the HP71B? Could be interesting how fast the calc with the HP71B FORTH would be?

regards
Erwin
Find all posts by this user
Quote this message in a reply
01-20-2017, 10:57 PM (This post was last modified: 01-20-2017 10:59 PM by KeithB.)
Post: #3
RE: HP Prime vs HP71 benchmark
Here is the 71B program:

Code:

10 H=0
20 T=0
30 RANDOMIZE 1
40 S=TIME
50 T=T+1
60 X=RND^2 + RND^2
70 IF X<= 1 THEN H=H+1
80 IF MOD(T,10000) = 0 THEN DISP USING 90; T/1000, 4*H/T, TIME-S
90 IMAGE DD,"KPI:", D.DDDDD, "ET:",DDDD.D
100 GOTO 50

I have a FORTH module, so if you have a FORTH word to run, I would be glad to try.

ETA: I guess I could try assembler, too.
Find all posts by this user
Quote this message in a reply
01-23-2017, 05:38 PM
Post: #4
RE: HP Prime vs HP71 benchmark
I just got the results using the CAS rand() function.

For 50,000 pairs:
Pi = 3.13752 Time = 59.752 seconds, or almost 7X slower than RANDOM().
Find all posts by this user
Quote this message in a reply
01-24-2017, 08:00 AM
Post: #5
RE: HP Prime vs HP71 benchmark
Hello,

The most surprising thing is that Prime is not much faster than the 71.

Prime runs at 400Mhz, I do not know how fast the 71 runs....
However, the 71, being based on a Saturn CPU also has slow instructions (ie, the instructions can take up to 15 or 20 CPU cycles to execute). Most Prime CPU instructions only take 1 cycle....

However, the Prime programming language will be much less efficient than the 71 as the 71 interpreted does not need to do any type of memory allocation or things like that while the prime will have to do a LOT of them.

BTW, you can optimize the Prime program as follow: It will run around 1.5 times faster I think...
EXPORT PI2()
BEGIN
H:=0;
T:=0;
S:=Ticks;
RANDSEED(1);
WHILE 1 DO
for A:= 1 to 10000 DO
H:= H+IP(RANDOM()^2+RANDOM()^2);
end;
T:= T+10000;
E:= TICKS-S;
PRINT("T:"+T+" PI:"+4*(T-H)/T+" E:"+E);
END;
END;

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
01-24-2017, 03:45 PM (This post was last modified: 01-24-2017 03:47 PM by KeithB.)
Post: #6
RE: HP Prime vs HP71 benchmark
Clever! I like the IP() trick!

Note that the Prime was faster than a naïve comparison of clocks would suggest.
Find all posts by this user
Quote this message in a reply
01-24-2017, 04:32 PM (This post was last modified: 01-24-2017 04:34 PM by KeithB.)
Post: #7
RE: HP Prime vs HP71 benchmark
Thanks cyrille.
But you have a bug*. H is supposed to be the number of hits *inside* the circle, not outside. I had to add an extra count and subtract that from 10000 to get things to work.

Anyway, that does speed things up as you said, it now takes about 5.1 seconds for 50000 iterations. That makes the prime about 1650 times faster than the HP71.

BTW, what is up with the 'C like' for loop? It works without a syntax error, but is not documented. Is any expression allowed in the place of the from?

ETA: OOPS, I did not see that you had corrected the PI calculation to correct for this, sorry.
Find all posts by this user
Quote this message in a reply
01-24-2017, 05:48 PM
Post: #8
RE: HP Prime vs HP71 benchmark
(01-24-2017 04:32 PM)KeithB Wrote:  BTW, what is up with the 'C like' for loop? It works without a syntax error, but is not documented. Is any expression allowed in the place of the from?

The for statement is documented which statement are you referring to?

Tom L

Tom L
...other than that, Mrs. Lincoln, what did you think of the play?
Find all posts by this user
Quote this message in a reply
01-24-2017, 06:13 PM
Post: #9
RE: HP Prime vs HP71 benchmark
The fact that he uses:

FOR A:=1 TO 10000 DO

Instead of

FOR A FROM 1 TO 10000 DO

Leaving out the FROM is not documented.
Find all posts by this user
Quote this message in a reply
01-24-2017, 08:08 PM
Post: #10
RE: HP Prime vs HP71 benchmark
(01-24-2017 06:13 PM)KeithB Wrote:  The fact that he uses:

FOR A:=1 TO 10000 DO

Instead of

FOR A FROM 1 TO 10000 DO

Leaving out the FROM is not documented.

Ha! You're right! I come from a BASIC background so I never even thought of putting FROM in there. I've always used the undocumented version. Maybe I should read the manual more often!

Tom L

Tom L
...other than that, Mrs. Lincoln, what did you think of the play?
Find all posts by this user
Quote this message in a reply
01-25-2017, 06:25 AM
Post: #11
RE: HP Prime vs HP71 benchmark
Hello,

Yes, both form do work....

Remember, you can also do a step and a downto in a for...

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
01-25-2017, 06:26 AM
Post: #12
RE: HP Prime vs HP71 benchmark
How does the WP 34S cope with this problem???

Pauli
Find all posts by this user
Quote this message in a reply
01-25-2017, 03:38 PM
Post: #13
RE: HP Prime vs HP71 benchmark
What problem?
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)