/** * Warm up the fork-join pool to account for any instruction/data * caching effects. */ private static void warmUpForkJoinPool() throws IOException, URISyntaxException { System.out.println("Warming up the fork-join pool"); // This object is used to search a recursive directory // containing the complete works of William Shakespeare. Folder folder = TestDataFactory .getRootFolder(sSHAKESPEARE_FOLDER, true); // Create the appropriate type of object. SearchWithForkJoinTask forkJoinTask = new SearchWithForkJoinTask(folder, mPhrasesToFind, true, true, true, true); // Use the common fork-join pool to search the input looking // for phrases that match. List<List<SearchResults>> listOfListOfSearchResults = ForkJoinPool.commonPool() .invoke(forkJoinTask); // Help the GC. //noinspection UnusedAssignment forkJoinTask = null; // Run the garbage collector after each test. System.gc(); }
/** * @return The input data in the given @a rootFolderName as a list * of CharSequences. */ public static List<CharSequence> getInput(String rootFolderName, boolean parallel) throws IOException, URISyntaxException { // Return the input data in the given @a rootFolderName as a // list of CharSequences. return new GetInputListTask(getRootFolder(rootFolderName, parallel) // Get all the subfolders. .getSubFolders(), parallel).compute(); }