Search in sources :

Example 1 with SearchBenchmarkTask

use of org.elasticsearch.client.benchmark.ops.search.SearchBenchmarkTask in project elasticsearch by elastic.

the class AbstractBenchmark method runSearchBenchmark.

@SuppressForbidden(reason = "system out is ok for a command line tool")
private void runSearchBenchmark(String[] args) throws Exception {
    if (args.length != 5) {
        System.err.println("usage: 'search' benchmarkTargetHostIp indexName searchRequestBody throughputRates");
        System.exit(1);
    }
    String benchmarkTargetHost = args[1];
    String indexName = args[2];
    String searchBody = args[3];
    List<Integer> throughputRates = Arrays.asList(args[4].split(",")).stream().map(Integer::valueOf).collect(Collectors.toList());
    T client = client(benchmarkTargetHost);
    try {
        runTrials(() -> {
            for (int throughput : throughputRates) {
                //GC between trials to reduce the likelihood of a GC occurring in the middle of a trial.
                runGc();
                BenchmarkRunner benchmark = new BenchmarkRunner(SEARCH_BENCHMARK_ITERATIONS, SEARCH_BENCHMARK_ITERATIONS, new SearchBenchmarkTask(searchRequestExecutor(client, indexName), searchBody, SEARCH_BENCHMARK_ITERATIONS, SEARCH_BENCHMARK_ITERATIONS, throughput));
                System.out.printf("Target throughput = %d ops / s%n", throughput);
                benchmark.run();
            }
        });
    } finally {
        client.close();
    }
}
Also used : SearchBenchmarkTask(org.elasticsearch.client.benchmark.ops.search.SearchBenchmarkTask) SuppressForbidden(org.elasticsearch.common.SuppressForbidden)

Aggregations

SearchBenchmarkTask (org.elasticsearch.client.benchmark.ops.search.SearchBenchmarkTask)1 SuppressForbidden (org.elasticsearch.common.SuppressForbidden)1