我标杆一些代码,我不能让它以最快的速度奔跑着java.math.BigInteger
使用完全相同的算法,即使.所以我将java.math.BigInteger
source 复制到我自己的包中并尝试了这个:
//import java.math.BigInteger;
public class MultiplyTest {
public static void main(String[] args) {
Random r = new Random(1);
long tm = 0, count = 0,result=0;
for (int i = 0; i < 400000; i++) {
int s1 = 400, s2 = 400;
BigInteger a = new BigInteger(s1 * 8, r), b = new BigInteger(s2 * 8, r);
long tm1 = System.nanoTime();
BigInteger c = a.multiply(b);
if (i > 100000) {
tm += System.nanoTime() - tm1; …
Run Code Online (Sandbox Code Playgroud)