Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Are you willing to try it? Calculator benchmark: find primes in a ultra naive way

210 views
Skip to first unread message

Pier Aiello

unread,
Sep 12, 2013, 12:33:27 PM9/12/13
to
The code is:
#########
input: n
--
for k:=3 to n do {
for j:=2 to k-1 do {
if ( k mod j == 0 ) then {
j:= k-1 //so we exit from the inner for
}
}
}
#########

The result format is:
#########
A result is composed by the following list
- the device used plus the language used, eventual overclock, eventual custom firmware and so on.
- time elapsed for a given n in seconds (see below)
- the code used.

if the calculator is too slow, or limited, to compute a given n, then report "for n the computation takes too much time" (or skip the computation). Conversely, if the calculator is too fast to compute a given n, then report "for n the computation takes too little time, i skipped it"
#########

The options are
#########
n:= 100
n:= 1000
For very fast implementations:
n:= 10000
n:= 100000
#########

The benchmark page is on a wiki editable by registered users
< http://www.wiki4hp.com/doku.php?id=benchmarks:ultranaiveprimes >

There is also a discussion on the hpmuseum, but it is not archived (search for: New "simpler" benchmark: Ultra naive search for primes, ).
The discussion on the casio forum
< http://community.casiocalc.org/topic/7183-help-needed-calculator-benchmark/ >

But the TI community is not so collaborative :(

I hope that someone with old/new HP calculator will report his results!

And thanks!

Joe Horn

unread,
Sep 12, 2013, 7:35:55 PM9/12/13
to
Pier: Please feel free to add the following data to your "Ultra Naïve Primes Benchmark" wiki page.

HP-71B, native BASIC, ROM version 1BBBB, Saturn @ 640 kHz (default)

10 T=TIME
20 INPUT N
30 FOR K=3 TO N
40 FOR J=2 TO K-1
50 IF MOD(K,J)=0 THEN J=K-1
60 NEXT J
70 NEXT K
80 DISP TIME-T

N:=10
Time: 0.6 s

N:=100
Time: 27.31 s

N:=1000
Time: 1694.s s

-Joe-

Pier Aiello

unread,
Sep 13, 2013, 2:42:07 AM9/13/13
to
On Friday, September 13, 2013 1:35:55 AM UTC+2, Joe Horn wrote:
> Pier: Please feel free to add the following data to your "Ultra Naïve Primes Benchmark" wiki page.

Thanks but it is not mine! It's ours! It's a wiki!

Travis Evans

unread,
Sep 14, 2013, 12:15:32 PM9/14/13
to
Here are my HP 50g results:

ROM 2.15, processor at standard 75 MHz, UserRPL
n=100: ~8.9s
n=1000: ~546.6s
Code:
@ n -> seconds_elapsed
\<< TICKS SWAP 1. + 3. SWAP FOR K
2. K FOR J
IF K J MOD 0 == THEN
K 'J' STO
END
NEXT
NEXT TICKS SWAP - B\->R 8192. /
\>>

ROM 2.15, processor at standard 75 MHz, SysRPL
n=100: ~0.6s
n=1000: ~81.6s
Code:
* n -> seconds_elapsed
::
CK1NOLASTWD
CK&DISPATCH1
real
::
CLKTICKS
SWAP COERCE #1+ THREE DO
INDEX@ TWO DO
JINDEX@ INDEX@ #/ DROP
#0= IT ExitAtLOOP
LOOP
ATTN? IT ExitAtLOOP
LOOP
CLKTICKS SWAP bit- HXS>% %8192 %/
;
;

I didn't do the n=10,000 and n=100,000 tests because the execution times
seem to follow some sort of exponential-like or faster growth and I
don't have the patience. :-)

--
Travis

Pier Aiello

unread,
Sep 14, 2013, 6:43:46 PM9/14/13
to
Not exponential, just quadratic (in terms of order of magnitude) for each step. If the order of magnitude increase by one, from 10^r to 10^(r+1) then the time increase by 2 (ord. of magn.). So with 81.6 s i expect something like 9'000 secs for n=10.000

Pier Aiello

unread,
Sep 14, 2013, 6:45:23 PM9/14/13
to
You can see the math on the end of the wiki previously linked!
0 new messages