public void testPerformance() throws IOException {
        final int MRUNS = 8;
        final int IRUNS = 10;
        int detected = 0; // To avoid code removal by JVM or compiler
        String lastResult = null;
        for (int m = 0; m < MRUNS; m++) {
            LanguageProfile.useInterleaved =
                    (m & 1) == 1; // Alternate between standard and interleaved
            StringBuilder currentResult = new StringBuilder();
            final long start = System.nanoTime();
            for (int i = 0; i < IRUNS; i++) {
                for (String language : languages) {
                    ProfilingWriter writer = new ProfilingWriter();
                    writeTo(language, writer);
                    LanguageIdentifier identifier = new LanguageIdentifier(writer.getProfile());
                    if (identifier.isReasonablyCertain()) {
                        currentResult.append(identifier.getLanguage());
                        detected++;
                    }
                }
            }
            System.out.printf(Locale.ROOT,
                    "Performed %d detections at %2d ms/test with interleaved=%b%n",
                    languages.length * IRUNS,
                    (System.nanoTime() - start) / 1000000 / (languages.length * IRUNS),
                    LanguageProfile.useInterleaved);
            if (lastResult !=
                    null) { // Might as well test that they behave the same while we're at it
                assertEquals("This result should be equal to the last", lastResult, currentResult.toString());
            }
            lastResult = currentResult.toString();
        }
        if (detected == -1) {
            System.out.println(
                    "Never encountered but keep it to guard against over-eager optimization");
        }
    }
JUnit based test of class {@link LanguageIdentifier}.

@author Sami Siren
@author Jerome Charron - http://frutch.free.fr/
tika-langdetect/tika-langdetect-tika/src/test/java/org/apache/tika/langdetect/tika/LanguageIdentifierTest.java