/** * Return the fastest available {@link LZ4Factory} instance which does not * rely on JNI bindings. It first tries to load the * {@link #unsafeInstance() unsafe instance}, and then the * {@link #safeInstance() safe Java instance} if the JVM doesn't have a * working {@link sun.misc.Unsafe}. */ public static LZ4Factory fastestJavaInstance() { if (Utils.isUnalignedAccessAllowed()) { try { return unsafeInstance(); } catch (Throwable t) { return safeInstance(); } } else { return safeInstance(); } }
/** * Return the fastest available {@link LZ4Factory} instance which does not * rely on JNI bindings. It first tries to load the * {@link #unsafeInstance() unsafe instance}, and then the * {@link #safeInstance() safe Java instance} if the JVM doesn't have a * working {@link sun.misc.Unsafe}. */ public static LZ4Factory fastestJavaInstance() { if (Utils.isUnalignedAccessAllowed()) { try { return unsafeInstance(); } catch (Throwable t) { return safeInstance(); } } else { return safeInstance(); } }
}); LZ4Compressor unsafeCompressor = LZ4Factory.unsafeInstance().fastCompressor(); benchmarkFunction("LZ4 (Unsafe)", set.length, () -> { return benchMarkLZ4(unsafeCompressor, set);