/** * Test each file, one at a time in multiple threads. * This was required to test TIKA-2519 in a reasonable * amount of time. This forced the parser to use the * same underlying memory structures because it was the same file. * This is stricter than I think our agreement with clients is * because this run tests on literally the same file and * not a copy of the file per thread. Let's leave this as is * unless there's a good reason to create a separate copy per thread. * * @param files files to test, one at a time * @param numThreads number of threads to use * @param numIterations number of iterations per thread */ protected void testEach(Parser parser, Path[] files, ParseContext[] parseContext, int numThreads, int numIterations) { for (Path p : files) { Path[] toTest = new Path[1]; toTest[0] = p; testAll(parser, toTest, parseContext, numThreads, numIterations); } }
/** * This calls {@link #testEach(Parser parser, Path[], ParseContext[], int, int)} and * then {@link #testAll(Parser parser, Path[], ParseContext[], int, int)} * * @param numThreads number of threads to use * @param numIterations number of iterations per thread * @param filter file filter to select files from "/test-documents"; if <code>null</code>, * all files will be used * @throws Exception */ protected void testMultiThreaded(Parser parser, ParseContext[] parseContext, int numThreads, int numIterations, FileFilter filter) throws Exception { Path[] allFiles = getTestFiles(filter); testEach(parser, allFiles, parseContext, numThreads, numIterations); testAll(parser, allFiles, parseContext, numThreads, numIterations); }