1919
2020import java .util .Objects ;
2121import java .util .Random ;
22- import java .util .function .ToIntFunction ;
22+ import java .util .function .LongToIntFunction ;
2323import org .apache .hadoop .test .LambdaTestUtils ;
2424import org .junit .jupiter .api .Test ;
2525import org .junit .jupiter .api .Timeout ;
@@ -91,7 +91,7 @@ public void testComposeCrc32CZeroLength() {
9191 */
9292 private static void doTestComposeCrc (
9393 byte [] data , DataChecksum .Type type , int chunkSize , boolean useMonomial ) {
94- final ToIntFunction < Long > mod = DataChecksum .getModFunction (type );
94+ final LongToIntFunction mod = DataChecksum .getModFunction (type );
9595
9696 // Get full end-to-end CRC in a single shot first.
9797 DataChecksum checksum = DataChecksum .newDataChecksum (
@@ -142,7 +142,7 @@ private static void doTestComposeCrcZerolength(DataChecksum.Type type) {
142142 // Without loss of generality, we can pick any integer as our fake crcA
143143 // even if we don't happen to know the preimage.
144144 int crcA = 0xCAFEBEEF ;
145- final ToIntFunction < Long > mod = DataChecksum .getModFunction (type );
145+ final LongToIntFunction mod = DataChecksum .getModFunction (type );
146146 DataChecksum checksum = DataChecksum .newDataChecksum (
147147 type , Integer .MAX_VALUE );
148148 Objects .requireNonNull (checksum , "checksum" );
@@ -230,7 +230,7 @@ public void testMultiplyMod() {
230230 private static long [] runTestMultiplyMod (int n , DataChecksum .Type type ) {
231231 System .out .printf ("Run %s with %d computations%n" , type , n );
232232 final int polynomial = getCrcPolynomialForType (type );
233- final ToIntFunction < Long > mod = DataChecksum .getModFunction (type );
233+ final LongToIntFunction mod = DataChecksum .getModFunction (type );
234234
235235 final int [] p = new int [n ];
236236 final int [] q = new int [n ];
@@ -256,8 +256,8 @@ private static long[] runTestMultiplyMod(int n, DataChecksum.Type type) {
256256 }
257257 times [1 ] = System .currentTimeMillis () - t1 ;
258258 final double ops1 = n * 1000.0 / times [1 ];
259- System .out .printf ("multiplyCrc32 : %.3fs (%.2f ops)%n" , times [1 ] / 1000.0 , ops1 );
260- System .out .printf ("multiplyCrc32 is %.2f%% faster%n" , (ops1 - ops0 ) * 100.0 / ops0 );
259+ System .out .printf ("tableMultiply : %.3fs (%.2f ops)%n" , times [1 ] / 1000.0 , ops1 );
260+ System .out .printf ("tableMultiply ops is %.2f%% faster%n" , (ops1 - ops0 ) * 100.0 / ops0 );
261261
262262 for (int i = 0 ; i < n ; i ++) {
263263 if (expected [i ] != computed [i ]) {
@@ -354,11 +354,11 @@ public static void main(String[] args) throws Exception {
354354 }
355355
356356 System .out .printf ("%nResult) %d x %d computations:%n" , m , n );
357- final double ops0 = n * 1000.0 / times [0 ];
357+ final double ops0 = m * n * 1000.0 / times [0 ];
358358 System .out .printf ("galoisFieldMultiply: %.3fs (%.2f ops)%n" , times [0 ] / 1000.0 , ops0 );
359- final double ops1 = n * 1000.0 / times [1 ];
360- System .out .printf ("multiplyCrc32 : %.3fs (%.2f ops)%n" , times [1 ] / 1000.0 , ops1 );
361- System .out .printf ("multiplyCrc32 is %.2f%% faster%n" , (ops1 - ops0 ) * 100.0 / ops0 );
359+ final double ops1 = m * n * 1000.0 / times [1 ];
360+ System .out .printf ("tableMultiply : %.3fs (%.2f ops)%n" , times [1 ] / 1000.0 , ops1 );
361+ System .out .printf ("tableMultiply ops is %.2f%% faster%n" , (ops1 - ops0 ) * 100.0 / ops0 );
362362 }
363363 }
364364}
0 commit comments