| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 | import java.math.BigInteger;
|
|---|
| 5 |
|
|---|
| 6 | import edu.udel.cis.vsl.sarl.IF.number.IntegerNumber;
|
|---|
| 7 | import edu.udel.cis.vsl.sarl.IF.number.NumberFactory;
|
|---|
| 8 | import edu.udel.cis.vsl.sarl.number.IF.Numbers;
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | public 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 |
|
|---|
| 48 | public 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 |
|
|---|
| 61 | public 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 |
|
|---|
| 73 | public 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 |
|
|---|
| 85 | public 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 |
|
|---|
| 97 | public 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 |
|
|---|
| 109 | public 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 |
|
|---|
| 121 | public 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 | }
|
|---|