Skip to content

Commit 69bfec6

Browse files
committed
initialize factorizer in setup() to avoid constructor cost for each test
method
1 parent 2f08eeb commit 69bfec6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+59
-184
lines changed

src/test/java/de/tilman_neumann/jml/factor/CombinedFactorAlgorithm1ThreadTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ public class CombinedFactorAlgorithm1ThreadTest extends FactorTestBase {
2626

2727
private boolean RUN_SLOW_TESTS_TOO = false;
2828

29-
public CombinedFactorAlgorithm1ThreadTest() {
30-
super(new CombinedFactorAlgorithm(1, null, true));
31-
}
32-
3329
@BeforeClass
3430
public static void setup() {
3531
ConfigUtil.initProject();
32+
setFactorizer(new CombinedFactorAlgorithm(1, null, true));
3633
}
3734

3835
@Test

src/test/java/de/tilman_neumann/jml/factor/CombinedFactorAlgorithm2ThreadsTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ public class CombinedFactorAlgorithm2ThreadsTest extends FactorTestBase {
2626

2727
private boolean RUN_SLOW_TESTS_TOO = false;
2828

29-
public CombinedFactorAlgorithm2ThreadsTest() {
30-
// gitgub CI results for the 236 bit test number:
31-
// 1 thread -> 22s, 2 threads -> 12s, 4 threads -> 14s.
32-
// Using 2 threads looks best so far.
33-
super(new CombinedFactorAlgorithm(2, null, true));
34-
}
35-
3629
@BeforeClass
3730
public static void setup() {
3831
ConfigUtil.initProject();
32+
// gitgub CI results for the 236 bit test number:
33+
// 1 thread -> 22s, 2 threads -> 12s, 4 threads -> 14s.
34+
// Using 2 threads looks best so far.
35+
setFactorizer(new CombinedFactorAlgorithm(2, null, true));
3936
}
4037

4138
@Test

src/test/java/de/tilman_neumann/jml/factor/FactorTestBase.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ public class FactorTestBase {
4040

4141
private static final BPSWTest bpsw = new BPSWTest();
4242

43-
private FactorAlgorithm factorizer, verificationFactorizer;
43+
private static FactorAlgorithm factorizer;
44+
private static FactorAlgorithm verificationFactorizer;
4445

45-
public FactorTestBase(FactorAlgorithm factorizer) {
46-
this(factorizer, FactorAlgorithm.getDefault());
46+
protected static void setFactorizer(FactorAlgorithm factorizer) {
47+
FactorTestBase.setFactorizer(factorizer, FactorAlgorithm.getDefault());
4748
}
4849

49-
public FactorTestBase(FactorAlgorithm factorizer, FactorAlgorithm verificationFactorizer) {
50-
this.factorizer = factorizer;
51-
this.verificationFactorizer = verificationFactorizer;
50+
protected static void setFactorizer(FactorAlgorithm factorizer, FactorAlgorithm verificationFactorizer) {
51+
FactorTestBase.factorizer = factorizer;
52+
FactorTestBase.verificationFactorizer = verificationFactorizer;
5253
}
5354

5455
/**

src/test/java/de/tilman_neumann/jml/factor/cfrac/CFrac63Test.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@
4141
*/
4242
public class CFrac63Test extends FactorTestBase {
4343

44-
public CFrac63Test() {
45-
super(new CFrac63(true, 5, 1.5F, 0.152F, 0.25F, new TDiv_CF63_01(), new MatrixSolverGauss02(), 3));
46-
}
47-
4844
@BeforeClass
4945
public static void setup() {
5046
ConfigUtil.initProject();
47+
setFactorizer(new CFrac63(true, 5, 1.5F, 0.152F, 0.25F, new TDiv_CF63_01(), new MatrixSolverGauss02(), 3));
5148
}
5249

5350
@Test

src/test/java/de/tilman_neumann/jml/factor/cfrac/CFracTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@
4141
*/
4242
public class CFracTest extends FactorTestBase {
4343

44-
public CFracTest() {
45-
super(new CFrac(true, 5, 1.5F, 0.152F, 0.253F, new TDiv_CF01(), new MatrixSolverGauss02(), 5));
46-
}
47-
4844
@BeforeClass
4945
public static void setup() {
5046
ConfigUtil.initProject();
47+
setFactorizer(new CFrac(true, 5, 1.5F, 0.152F, 0.253F, new TDiv_CF01(), new MatrixSolverGauss02(), 5));
5148
}
5249

5350
@Test

src/test/java/de/tilman_neumann/jml/factor/ecm/EllipticCurveMethodTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@
2121

2222
public class EllipticCurveMethodTest extends FactorTestBase {
2323

24-
public EllipticCurveMethodTest() {
25-
super(new EllipticCurveMethod(-1));
26-
}
27-
2824
@BeforeClass
2925
public static void setup() {
3026
ConfigUtil.initProject();
27+
setFactorizer(new EllipticCurveMethod(-1));
3128
}
3229

3330
@Test

src/test/java/de/tilman_neumann/jml/factor/ecm/TinyEcm64MHInlinedTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525

2626
public class TinyEcm64MHInlinedTest extends FactorTestBase {
2727

28-
public TinyEcm64MHInlinedTest() {
29-
super(new TinyEcm64MHInlined());
30-
}
31-
3228
@BeforeClass
3329
public static void setup() {
3430
ConfigUtil.initProject();
31+
setFactorizer(new TinyEcm64MHInlined());
3532
}
3633

3734
@Test

src/test/java/de/tilman_neumann/jml/factor/ecm/TinyEcm64MHTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525

2626
public class TinyEcm64MHTest extends FactorTestBase {
2727

28-
public TinyEcm64MHTest() {
29-
super(new TinyEcm64MH());
30-
}
31-
3228
@BeforeClass
3329
public static void setup() {
3430
ConfigUtil.initProject();
31+
setFactorizer(new TinyEcm64MH());
3532
}
3633

3734
@Test

src/test/java/de/tilman_neumann/jml/factor/ecm/TinyEcm64Test.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525

2626
public class TinyEcm64Test extends FactorTestBase {
2727

28-
public TinyEcm64Test() {
29-
super(new TinyEcm64());
30-
}
31-
3228
@BeforeClass
3329
public static void setup() {
3430
ConfigUtil.initProject();
31+
setFactorizer(new TinyEcm64());
3532
}
3633

3734
@Test

src/test/java/de/tilman_neumann/jml/factor/hart/HartFast2Mult2Test.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@
3636
*/
3737
public class HartFast2Mult2Test extends FactorTestBase {
3838

39-
public HartFast2Mult2Test() {
40-
super(new HartFast2Mult2(false));
41-
}
42-
4339
@BeforeClass
4440
public static void setup() {
4541
ConfigUtil.initProject();
42+
setFactorizer(new HartFast2Mult2(false));
4643
}
4744

4845
@Test

0 commit comments

Comments
 (0)