I figured it out. It's the old version of JUnit that we're using.

Although we're building OpenJFX with Gradle 4.8, which bundles JUnit 4.12, our "build.gradle" file specifies the older JUnit 4.8.2 (which is downloaded, along with Hamcrest 1.1, into the Gradle cache under "~/.gradle/caches").

And JUnit 4.8.2 is more than 57 times slower than JUnit 4.12 when comparing primitive arrays!

The change that makes it so much faster is the call to "Arrays.deepEquals", not found in the older version:

public abstract class ComparisonCriteria {
    public void arrayEquals(String message,
            Object expecteds, Object actuals)
            throws ArrayComparisonFailure {
        if (expecteds == actuals
            || Arrays.deepEquals(
                new Object[] {expecteds}, new Object[] {actuals})) {
            // The reflection-based loop below is potentially very slow,
            // especially for primitive arrays. The deepEquals check
            // allows us to circumvent it in the usual case where the
            // arrays are exactly equal.
            return;
        }
        ...
    }
    ...
}

Mystery solved! Can we upgrade to JUnit 4.12 (and Hamcrest 1.3) in the build?

John

Reply via email to