private void initialize() { InternalFPF locFPF1 = new InternalFPF(); InternalFPF locFPF2 = new InternalFPF(); // Local random number. RandNum rndnum = new RandNum(); // Allocate arrays. aarray = new InternalFPF[array_rows]; barray = new InternalFPF[array_rows]; carray = new InternalFPF[array_rows]; // Instantiate objects. for (int i = 0; i < array_rows; i++) { aarray[i] = new InternalFPF(); barray[i] = new InternalFPF(); carray[i] = new InternalFPF(); } for (int i = 0; i < array_rows; i++) { locFPF1 = new InternalFPF(rndnum.nextwc(50000)); locFPF2 = new InternalFPF(rndnum.nextwc(50000) + 1); EmFloatPnt.DivideInternalFPF(locFPF1, locFPF2, aarray[i]); locFPF2 = new InternalFPF(rndnum.nextwc(50000) + 1); EmFloatPnt.DivideInternalFPF(locFPF1, locFPF2, barray[i]); } System.gc(); // Do garbage collection. }
private long DoIteration() { long testTime; // Duration of the test (milliseconds). int i; // Index. int locloops; // Local for loops. // Following is a "jump table" that defines which operation // will be performed per pass through the loop. Each pass // through the arrays performs operations in the following // ratios: // 4 adds, 4 subtracts, 5 multiplies, 3 divides // (adds and subtracts being nearly the same operation). byte[] jtable = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3}; locloops = loops_per_iter; // Set # of loops to perform. // Start the stopwatch. testTime = System.currentTimeMillis(); while ((locloops--) > 0) { for (i = 0; i < array_rows; i++) { if ((jtable[i % 16]) == 0) { // Add. EmFloatPnt.AddSubInternalFPF((byte) 0, aarray[i], barray[i], carray[i]); } else if ((jtable[i % 16]) == 1) { // Subtract. EmFloatPnt.AddSubInternalFPF((byte) 1, aarray[i], barray[i], carray[i]); } else if ((jtable[i % 16]) == 2) { // Multiply. EmFloatPnt.MultiplyInternalFPF(aarray[i], barray[i], carray[i]); } else if ((jtable[i % 16]) == 3) { // Divide. EmFloatPnt.DivideInternalFPF(aarray[i], barray[i], carray[i]); } } } return (System.currentTimeMillis() - testTime); }