Search in sources :

Example 1 with Sample

use of org.elasticsearch.client.benchmark.metrics.Sample in project elasticsearch by elastic.

the class BenchmarkRunner method run.

@SuppressForbidden(reason = "system out is ok for a command line tool")
public void run() {
    SampleRecorder recorder = new SampleRecorder(iterations);
    System.out.printf("Running %s with %d warmup iterations and %d iterations.%n", task.getClass().getSimpleName(), warmupIterations, iterations);
    try {
        task.setUp(recorder);
        task.run();
        task.tearDown();
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
        return;
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    List<Sample> samples = recorder.getSamples();
    final List<Metrics> summaryMetrics = MetricsCalculator.calculate(samples);
    if (summaryMetrics.isEmpty()) {
        System.out.println("No results.");
    }
    for (Metrics metrics : summaryMetrics) {
        String throughput = String.format(Locale.ROOT, "Throughput [ops/s]: %f", metrics.throughput);
        String serviceTimes = String.format(Locale.ROOT, "Service time [ms]: p50 = %f, p90 = %f, p95 = %f, p99 = %f, p99.9 = %f, p99.99 = %f", metrics.serviceTimeP50, metrics.serviceTimeP90, metrics.serviceTimeP95, metrics.serviceTimeP99, metrics.serviceTimeP999, metrics.serviceTimeP9999);
        String latencies = String.format(Locale.ROOT, "Latency [ms]:      p50 = %f, p90 = %f, p95 = %f, p99 = %f, p99.9 = %f, p99.99 = %f", metrics.latencyP50, metrics.latencyP90, metrics.latencyP95, metrics.latencyP99, metrics.latencyP999, metrics.latencyP9999);
        int lineLength = Math.max(serviceTimes.length(), latencies.length());
        System.out.println(repeat(lineLength, '-'));
        System.out.println(throughput);
        System.out.println(serviceTimes);
        System.out.println(latencies);
        System.out.printf("success count = %d, error count = %d%n", metrics.successCount, metrics.errorCount);
        System.out.println(repeat(lineLength, '-'));
    }
}
Also used : Metrics(org.elasticsearch.client.benchmark.metrics.Metrics) Sample(org.elasticsearch.client.benchmark.metrics.Sample) SampleRecorder(org.elasticsearch.client.benchmark.metrics.SampleRecorder) SuppressForbidden(org.elasticsearch.common.SuppressForbidden)

Example 2 with Sample

use of org.elasticsearch.client.benchmark.metrics.Sample in project elasticsearch by elastic.

the class SearchBenchmarkTask method runIterations.

private void runIterations(int iterations, boolean addSample) {
    long interval = TimeUnit.SECONDS.toNanos(1L) / targetThroughput;
    long totalStart = System.nanoTime();
    for (int iteration = 0; iteration < iterations; iteration++) {
        long expectedStart = totalStart + iteration * interval;
        while (System.nanoTime() < expectedStart) {
        // busy spin
        }
        long start = System.nanoTime();
        boolean success = searchRequestExecutor.search(searchRequestBody);
        long stop = System.nanoTime();
        if (addSample) {
            sampleRecorder.addSample(new Sample("search", expectedStart, start, stop, success));
        }
    }
}
Also used : Sample(org.elasticsearch.client.benchmark.metrics.Sample)

Aggregations

Sample (org.elasticsearch.client.benchmark.metrics.Sample)2 Metrics (org.elasticsearch.client.benchmark.metrics.Metrics)1 SampleRecorder (org.elasticsearch.client.benchmark.metrics.SampleRecorder)1 SuppressForbidden (org.elasticsearch.common.SuppressForbidden)1