ah yeah, on 32-bit it's really-really slow.. (trying on my more powerful PC
instead of my old laptop for now)

soo.. the conclusion would be: Miller-Rabin is the fastest

http://pastie.org/8189939

ruby: 343s
jruby: 284s



On Tue, Jul 30, 2013 at 12:05 PM, Matthew Kerwin <lists / ruby-forum.com>wrote:

> I get the following, on an Ubuntu 64-bit VM (edited to fit the page
> width):
>
> prime.rb:44: warning: assigned but unused variable - rescnt
> prime.rb:85: warning: assigned but unused variable - rescnt
> prime.rb:119: warning: assigned but unused variable - rescnt
> prime.rb:159: warning: assigned but unused variable - rescnt
> prime.rb:165: warning: assigned but unused variable - modk
> prime.rb:212: warning: shadowing outer local variable - p
> Rehearsal -------------------------------------------------
> prime tests for P = 20000000000000003
> Miller-Rabin    0.000000   0.000000   0.000000 (  0.000761)
> primzp7?        2.290000   0.000000   2.290000 (  2.294709)
> primzp7a?       0.970000   0.000000   0.970000 (  0.971033)
> primzp7b?       0.980000   0.000000   0.980000 (  0.978331)
> primzp? 13      1.900000   0.010000   1.910000 (  1.905374)
> primzp? 17      1.870000   0.000000   1.870000 (  1.877343)
> primzpa? 13     3.200000   0.050000   3.250000 (  3.255519)
> primzpa? 17     3.100000   0.040000   3.140000 (  3.127512)
> factorzp 13     1.940000   0.000000   1.940000 (  1.949376)
> factorzp 17     1.870000   0.000000   1.870000 (  1.870068)
> prime? [ruby lib]
>                 26.550000   0.010000  26.560000 ( 26.569130)
> prime_division [ruby lib]
>                 29.570000   0.000000  29.570000 ( 29.585618)
> ---------------------------------------- total: 74.350000sec
>
>                 user     system      total        real
> prime tests for P = 20000000000000003
> Miller-Rabin    0.000000   0.000000   0.000000 (  0.000562)
> primzp7?        2.320000   0.000000   2.320000 (  2.319329)
> primzp7a?       0.980000   0.000000   0.980000 (  0.974572)
> primzp7b?       0.980000   0.000000   0.980000 (  0.984110)
> primzp? 13      1.920000   0.000000   1.920000 (  1.923894)
> primzp? 17      1.880000   0.010000   1.890000 (  1.884494)
> primzpa? 13     3.080000   0.030000   3.110000 (  3.109670)
> primzpa? 17     3.010000   0.020000   3.030000 (  3.028406)
> factorzp 13     1.910000   0.000000   1.910000 (  1.917429)
> factorzp 17     1.880000   0.000000   1.880000 (  1.875251)
> prime? [ruby lib]
>                 25.170000   0.000000  25.170000 ( 25.177364)
> prime_division [ruby lib]
>                 28.270000   0.020000  28.290000 ( 28.298034)
>
> [Kiswono Prayogo, note the durations, especially in the core methods;
> 10s is too short for calculating primality of large numbers. Have
> patience.]
>
> Note that all the warnings can be resolved by removing the unused
> definitions, and renaming that 'p' variable in the block.  They're
> messy, but unimportant.
>
> --
> Posted via http://www.ruby-forum.com/.
>
>


-- 
Regards,
Kiswono P
GB