static void runBenchmark( Client client, int maxIter, Results results, List<Entry<String, RequestInfo>> nativeSearchRequests, int minTerms, int warmerIter) throws IOException { int counter = 0; for (Entry<String, RequestInfo> entry : nativeSearchRequests) { SearchResponse searchResponse = null; // warm up for (int i = 0; i < warmerIter; i++) { searchResponse = client.search(entry.getValue().request).actionGet(); } System.gc(); // run benchmark StopWatch stopWatch = new StopWatch(); stopWatch.start(); for (int i = 0; i < maxIter; i++) { searchResponse = client.search(entry.getValue().request).actionGet(); } stopWatch.stop(); results.set( searchResponse, stopWatch, entry.getKey(), maxIter, counter, entry.getValue().numTerms); counter++; } results.printResults(null); }
@Override protected void printDocumentResults(Results results) { printSeparator(); Formatter formatter = new Formatter(System.out, Locale.US); formatter.format(" | Total: |"); results.printResults(formatter); }
public static void printOctaveScript(List<Results> allResults, String[] args) throws IOException { if (args.length == 0) { return; } try (BufferedWriter out = Files.newBufferedWriter(Paths.get(args[0]), StandardCharsets.UTF_8)) { out.write("#! /usr/local/bin/octave -qf"); out.write("\n\n\n\n"); out.write("######################################\n"); out.write("# Octave script for plotting results\n"); String filename = "scriptScoreBenchmark" + new DateTime().toString(); out.write( "#Call '" + args[0] + "' from the command line. The plot is then in " + filename + "\n\n"); out.write("handleArray = [];\n tagArray = [];\n plot([]);\n hold on;\n"); for (Results result : allResults) { out.write("\n"); out.write("# " + result.description); result.printResults(out); out.write( "handleArray = [handleArray, addToPlot(" + Results.NUM_TERMS + ", " + Results.TIME_PER_DOCIN_MILLIS + ", '" + result.color + "','" + result.lineStyle + "',5)];\n"); out.write("tagArray = [tagArray; '" + result.label + "'];\n"); out.write("\n"); } out.write("xlabel(\'number of query terms');"); out.write("ylabel(\'query time per document');"); out.write("legend(handleArray,tagArray);\n"); out.write("saveas(gcf,'" + filename + ".png','png')\n"); out.write("hold off;\n\n"); } catch (IOException e) { System.err.println("Error: " + e.getMessage()); } writeHelperFunction(); }
protected void printItemResults(int pageIndex, Results results) { Formatter formatter = new Formatter(System.out, Locale.US); formatter.format(" | %8d |", pageIndex + 1); results.printResults(formatter); }