System.out.println();
System.out.println("LargeInteger (StackContext) versus BigInteger");
BigInteger big = BigInteger.probablePrime(1024, new Random());
byte[] bytes = big.toByteArray();
LargeInteger large = LargeInteger.valueOf(bytes, 0, bytes.length);
System.out.print("LargeInteger (1024 bits) addition: ");
startTime();
for (int i = 0; i < 1000; i++) {
StackContext.enter();
for (int j = 0; j < results.length; j++) {
results[j] = large.plus(large);
}
StackContext.exit();
}
endTime(1000 * results.length);
System.out.print("LargeInteger (1024 bits) multiplication: ");
startTime();
for (int i = 0; i < 100; i++) {
StackContext.enter();
for (int j = 0; j < results.length; j++) {
results[j] = large.times(large);
}
StackContext.exit();
}
endTime(100 * results.length);