On Sunday, 4 March 2018 05:41:53 UTC-4, Jan Mercl wrote: > > On Sun, Mar 4, 2018 at 7:27 AM <ralphdo...@gmail.com <javascript:>> wrote: > > > It still has room for optimization, but it is much faster than > ProbablyPrime(0) for 32-bit integers. > > > http://nerdralph.blogspot.ca/2018/03/fast-small-prime-checker-in-golang.html > > You may want to give the primality checking functions of > http://github.com/cznic/mathutil a try. > > Running at a Intel® Core™ i5-4670 CPU @ 3.40GHz × 4 machine: > > ~/src/github.com/cznic/mathutil> go test -v -run @ -bench IsPrime |& tee > log > goos: linux > goarch: amd64 > pkg: github.com/cznic/mathutil > BenchmarkIsPrime-4 20000000 70.2 ns/op > BenchmarkIsPrimeUint64-4 500000 2558 ns/op > BenchmarkIsPrimeUint16-4 2000000000 0.28 ns/op > PASS > ok github.com/cznic/mathutil 23.360s > ~/src/github.com/cznic/mathutil> > > -- > > -j >
The performance looks to be as good or slightly better than my simple implementation. I might have gone with that if I had found it before... -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.