source: CIVL/mods/dev.civl.sarl/bench/GCDBenchmark.java@ cb4d4f4

main test-branch
Last change on this file since cb4d4f4 was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 3.3 KB
Line 
1
2
3
4import java.math.BigInteger;
5
6import edu.udel.cis.vsl.sarl.IF.number.IntegerNumber;
7import edu.udel.cis.vsl.sarl.IF.number.NumberFactory;
8import edu.udel.cis.vsl.sarl.number.IF.Numbers;
9
10
11
12public class GCDBenchmark {
13
14
15
16 private static NumberFactory factory = Numbers.REAL_FACTORY;
17
18 private static BigInteger bigOne = BigInteger.ONE;
19 private static BigInteger bigThirty = new BigInteger("30");
20 private static BigInteger bigTwenty = new BigInteger("20");
21 private static BigInteger bigThousand = new BigInteger("1000");
22 private static BigInteger bigTwoThousand = new BigInteger("2000");
23 private static BigInteger bigOneMillion = new BigInteger("1000000");
24 private static BigInteger bigTenMillion = new BigInteger("10000000");
25 private static BigInteger bigFiftyMillion = new BigInteger("50000000");
26 private static BigInteger bigOneHundredMillion = new BigInteger("100000000");
27 private static BigInteger bigOneBillion = new BigInteger("1000000000");
28 private static BigInteger bigFiveBillion = new BigInteger("5000000000");
29 private static BigInteger bigOneTrillion = new BigInteger("1000000000000");
30 private static BigInteger bigTenTrillion = new BigInteger("10000000000000");
31 private static BigInteger bigOneQuadrillion = new BigInteger("1000000000000000");
32 private static BigInteger bigTwoQuadrillion = new BigInteger("2000000000000000");
33
34
35 public void GCDBenchmark1() {
36
37 IntegerNumber a = factory.integer(bigThirty);
38 IntegerNumber b = factory.integer(bigTwenty);
39 long x = System.nanoTime();
40 factory.gcd(a, b);
41 long y = System.nanoTime();
42
43 System.out.println(y-x);
44
45 }
46
47
48public void GCDBenchmark2() {
49
50 IntegerNumber a = factory.integer(bigOne);
51 IntegerNumber b = factory.integer(bigTwenty);
52 long x = System.nanoTime();
53 factory.gcd(a, b);
54 long y = System.nanoTime();
55
56 System.out.println( y-x);
57
58 }
59
60
61public void GCDBenchmark3() {
62
63 IntegerNumber a = factory.integer(bigThousand);
64 IntegerNumber b = factory.integer(bigTwoThousand);
65 long x = System.nanoTime();
66 factory.gcd(a, b);
67 long y = System.nanoTime();
68
69 System.out.print(y-x);
70
71}
72
73public void GCDBenchmark4() {
74
75 IntegerNumber a = factory.integer(bigOneMillion);
76 IntegerNumber b = factory.integer(bigTenMillion);
77 long x = System.nanoTime();
78 factory.gcd(a, b);
79 long y = System.nanoTime();
80
81 System.out.print(y-x);
82
83}
84
85public void GCDBenchmark5() {
86
87 IntegerNumber a = factory.integer(bigFiftyMillion);
88 IntegerNumber b = factory.integer(bigOneHundredMillion);
89 long x = System.nanoTime();
90 factory.gcd(a, b);
91 long y = System.nanoTime();
92
93 System.out.print(y-x);
94
95}
96
97public void GCDBenchmark6() {
98
99 IntegerNumber a = factory.integer(bigOneBillion);
100 IntegerNumber b = factory.integer(bigFiveBillion);
101 long x = System.nanoTime();
102 factory.gcd(a, b);
103 long y = System.nanoTime();
104
105 System.out.print(y-x);
106
107}
108
109public void GCDBenchmark7() {
110
111 IntegerNumber a = factory.integer(bigOneTrillion);
112 IntegerNumber b = factory.integer(bigTenTrillion);
113 long x = System.nanoTime();
114 factory.gcd(a, b);
115 long y = System.nanoTime();
116
117 System.out.print(y-x);
118
119}
120
121public void GCDBenchmark8() {
122
123 IntegerNumber a = factory.integer(bigOneQuadrillion);
124 IntegerNumber b = factory.integer(bigTwoQuadrillion);
125 long x = System.nanoTime();
126 factory.gcd(a, b);
127 long y = System.nanoTime();
128
129 System.out.print(y-x);
130
131}
132}
Note: See TracBrowser for help on using the repository browser.