File tree Expand file tree Collapse file tree
src/test/java/de/tilman_neumann/jml/primes/exact Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020
2121import de .tilman_neumann .util .ConfigUtil ;
2222
23+ /**
24+ * Compare performance of prime tests for N<2^31.
25+ *
26+ * Currently fastest is LEMIRE_INT_TEST.isPrimeUnrolled(n).
27+ *
28+ * But since there are just 105.097.565 primes < 2^31 (Integer.MAX_VALUE = 2^31 - 1 being the biggest)
29+ * and 203.280.221 primes < 2^32, maybe soon we will simply store them and look then up...
30+ */
2331public class TDivPrimeTestPerformanceTest {
2432 private static final Logger LOG = LogManager .getLogger (TDivPrimeTestPerformanceTest .class );
2533
Original file line number Diff line number Diff line change 2222
2323import de .tilman_neumann .util .ConfigUtil ;
2424
25+ /**
26+ * Tests correctness of prime tests for N<2^31.
27+ *
28+ * Comparing the results of (established reference algorithm) BARRETT_TEST.isPrime_v1(n)
29+ * with (currently fastest) LEMIRE_INT_TEST.isPrimeUnrolled(n)
30+ * for all odd N<2^31 takes less than 10 minutes and shows no errors.
31+ */
2532public class TDivPrimeTestTest {
2633 private static final Logger LOG = LogManager .getLogger (TDivPrimeTestTest .class );
2734
@@ -42,7 +49,7 @@ public void testTDivPrimeTest() {
4249 test (2565572 );
4350
4451 // test many odd numbers
45- for (int n =3 ; n < 10000000 ; n +=2 ) {
52+ for (int n =3 ; n <= 10000000 /* Integer.MAX_VALUE */ ; n +=2 ) {
4653 test (n );
4754 }
4855
You can’t perform that action at this time.
0 commit comments