From af0a64ceb8f9cc91b2ea70958c619bfdc902983c Mon Sep 17 00:00:00 2001 From: Sakthivel Subramanian Date: Mon, 19 May 2025 17:21:45 +0530 Subject: [PATCH] chore: update benchmarking script --- benchmarks/pom.xml | 19 +-- .../spanner/benchmark/AbstractRunner.java | 91 +++++++++--- .../spanner/benchmark/BenchmarkRunner.java | 17 ++- .../benchmark/BenchmarkingConfiguration.java | 115 +++++++++++++++ .../spanner/benchmark/JavaClientRunner.java | 137 +++++++++++------- .../spanner/benchmark/LatencyBenchmark.java | 74 +++++++--- 6 files changed, 341 insertions(+), 112 deletions(-) create mode 100644 benchmarks/src/main/java/com/google/cloud/spanner/benchmark/BenchmarkingConfiguration.java diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index 28fef176ccc..0abf037b8c1 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -34,7 +34,7 @@ UTF-8 UTF-8 2.10.1 - 1.50.0 + 1.47.0 @@ -54,7 +54,12 @@ com.google.cloud.opentelemetry exporter-metrics - 0.34.0 + 0.33.0 + + + com.google.cloud + google-cloud-monitoring + 3.63.0 @@ -85,7 +90,7 @@ io.opentelemetry opentelemetry-bom - 1.50.0 + 1.47.0 pom import @@ -94,11 +99,6 @@ google-cloud-spanner 6.93.0 - - commons-cli - commons-cli - 1.9.0 - com.google.auto.value auto-value-annotations @@ -140,8 +140,9 @@ - com.coveo + com.spotify.fmt fmt-maven-plugin + 2.27 diff --git a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/AbstractRunner.java b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/AbstractRunner.java index 76460891299..b233cedaf22 100644 --- a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/AbstractRunner.java +++ b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/AbstractRunner.java @@ -18,46 +18,80 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; abstract class AbstractRunner implements BenchmarkRunner { - static final int TOTAL_RECORDS = 1000000; - static final String SELECT_QUERY = "SELECT ID FROM FOO WHERE ID = @id"; - static final String UPDATE_QUERY = "UPDATE FOO SET BAR=1 WHERE ID = @id"; + static final int TOTAL_RECORDS = 100000; + static final String TABLE_NAME = "Employees"; + static final String SELECT_QUERY = String.format("SELECT ID FROM %s WHERE ID = @id", TABLE_NAME); + static final String UPDATE_QUERY = + String.format("UPDATE %s SET Name=Google WHERE ID = @id", TABLE_NAME); static final String ID_COLUMN_NAME = "id"; - static final String SERVER_URL = "https://staging-wrenchworks.sandbox.googleapis.com"; + static final Map SERVER_URL_MAPPING = new HashMap<>(); - private final AtomicInteger operationCounter = new AtomicInteger(); + static { + SERVER_URL_MAPPING.put( + Environment.CLOUD_DEVEL, "https://staging-wrenchworks.sandbox.googleapis.com"); + SERVER_URL_MAPPING.put(Environment.PROD, "https://spanner.googleapis.com"); + } + + Map timerConfigurations = new HashMap<>(); + private final Set completedClients = new HashSet<>(); + private final Set finishedClients = new HashSet<>(); + + protected void initiateTimer(int clientId, String message, Instant endTime) { + TimerConfiguration timerConfiguration = + timerConfigurations.getOrDefault(clientId, new TimerConfiguration()); + timerConfiguration.setMessage(message); + timerConfiguration.setEndTime(endTime); + timerConfigurations.put(clientId, timerConfiguration); + } - protected void incOperations() { - operationCounter.incrementAndGet(); + protected void setBenchmarkingCompleted(int clientId) { + this.completedClients.add(clientId); } protected List collectResults( ExecutorService service, List>> results, - int numClients, - int numOperations) + BenchmarkingConfiguration configuration) throws Exception { - int totalOperations = numClients * numOperations; + while (!(finishedClients.size() == configuration.getNumOfClients())) + for (int i = 0; i < configuration.getNumOfClients(); i++) { + TimerConfiguration timerConfiguration = + timerConfigurations.getOrDefault(i, new TimerConfiguration()); + long totalSeconds = + ChronoUnit.SECONDS.between(Instant.now(), timerConfiguration.getEndTime()); + if (completedClients.contains(i)) { + if (!finishedClients.contains(i)) { + System.out.printf("Client %s: Completed", i); + finishedClients.add(i); + } + } else { + System.out.printf( + "Client %s: %s %s Minutes %s Seconds\r", + i + 1, timerConfiguration.getMessage(), totalSeconds / 60, totalSeconds % 60); + } + //noinspection BusyWait + Thread.sleep(1000L); + } service.shutdown(); - while (!service.isTerminated()) { - //noinspection BusyWait - Thread.sleep(1000L); - System.out.printf("\r%d/%d", operationCounter.get(), totalOperations); - } - System.out.println(); if (!service.awaitTermination(60L, TimeUnit.MINUTES)) { throw new TimeoutException(); } - List allResults = new ArrayList<>(numClients * numOperations); + List allResults = new ArrayList<>(); for (Future> result : results) { allResults.addAll(result.get()); } @@ -77,4 +111,25 @@ protected String generateRandomString() { ThreadLocalRandom.current().nextBytes(bytes); return new String(bytes, StandardCharsets.UTF_8); } + + static class TimerConfiguration { + private Instant endTime = Instant.now(); + private String message = "Waiting for benchmarks to start..."; + + Instant getEndTime() { + return endTime; + } + + void setEndTime(Instant endTime) { + this.endTime = endTime; + } + + String getMessage() { + return message; + } + + void setMessage(String message) { + this.message = message; + } + } } diff --git a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/BenchmarkRunner.java b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/BenchmarkRunner.java index 7a731887a86..4f8a77c3a1d 100644 --- a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/BenchmarkRunner.java +++ b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/BenchmarkRunner.java @@ -19,17 +19,18 @@ import java.time.Duration; import java.util.List; -public interface BenchmarkRunner { +interface BenchmarkRunner { enum TransactionType { - READ_ONLY_SINGLE_USE, + READ_ONLY_SINGLE_USE_READ, + READ_ONLY_SINGLE_USE_QUERY, READ_ONLY_MULTI_USE, READ_WRITE } - List execute( - TransactionType transactionType, - int numClients, - int numOperations, - int waitMillis, - boolean useMultiplexedSession); + enum Environment { + PROD, + CLOUD_DEVEL + } + + List execute(BenchmarkingConfiguration configuration); } diff --git a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/BenchmarkingConfiguration.java b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/BenchmarkingConfiguration.java new file mode 100644 index 00000000000..e3003cf58a1 --- /dev/null +++ b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/BenchmarkingConfiguration.java @@ -0,0 +1,115 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.spanner.benchmark; + +import com.google.cloud.spanner.DatabaseId; +import com.google.cloud.spanner.benchmark.BenchmarkRunner.Environment; +import com.google.cloud.spanner.benchmark.BenchmarkRunner.TransactionType; + +class BenchmarkingConfiguration { + + private DatabaseId databaseId; + private int numOfClients; + private int staleness; + private int warmupTime; + private int executionTime; + private int waitBetweenRequests; + private boolean useMultiplexSession; + private TransactionType transactionType; + private Environment environment; + + int getExecutionTime() { + return executionTime; + } + + BenchmarkingConfiguration setExecutionTime(int executionTime) { + this.executionTime = executionTime; + return this; + } + + DatabaseId getDatabaseId() { + return databaseId; + } + + BenchmarkingConfiguration setDatabaseId(DatabaseId databaseId) { + this.databaseId = databaseId; + return this; + } + + int getNumOfClients() { + return numOfClients; + } + + BenchmarkingConfiguration setNumOfClients(int numOfClients) { + this.numOfClients = numOfClients; + return this; + } + + int getStaleness() { + return staleness; + } + + BenchmarkingConfiguration setStaleness(int staleness) { + this.staleness = staleness; + return this; + } + + int getWarmupTime() { + return warmupTime; + } + + BenchmarkingConfiguration setWarmupTime(int warmupTime) { + this.warmupTime = warmupTime; + return this; + } + + int getWaitBetweenRequests() { + return waitBetweenRequests; + } + + BenchmarkingConfiguration setWaitBetweenRequests(int waitBetweenRequests) { + this.waitBetweenRequests = waitBetweenRequests; + return this; + } + + boolean isUseMultiplexSession() { + return useMultiplexSession; + } + + BenchmarkingConfiguration setUseMultiplexSession(boolean useMultiplexSession) { + this.useMultiplexSession = useMultiplexSession; + return this; + } + + TransactionType getTransactionType() { + return transactionType; + } + + BenchmarkingConfiguration setTransactionType(TransactionType transactionType) { + this.transactionType = transactionType; + return this; + } + + Environment getEnvironment() { + return environment; + } + + BenchmarkingConfiguration setEnvironment(Environment environment) { + this.environment = environment; + return this; + } +} diff --git a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/JavaClientRunner.java b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/JavaClientRunner.java index 6fc0842f376..ebe8f3bbaab 100644 --- a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/JavaClientRunner.java +++ b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/JavaClientRunner.java @@ -20,6 +20,8 @@ import com.google.cloud.opentelemetry.trace.TraceExporter; import com.google.cloud.spanner.DatabaseClient; import com.google.cloud.spanner.DatabaseId; +import com.google.cloud.spanner.Key; +import com.google.cloud.spanner.KeySet; import com.google.cloud.spanner.ReadOnlyTransaction; import com.google.cloud.spanner.ResultSet; import com.google.cloud.spanner.SessionPoolOptions; @@ -28,12 +30,11 @@ import com.google.cloud.spanner.SpannerExceptionFactory; import com.google.cloud.spanner.SpannerOptions; import com.google.cloud.spanner.Statement; +import com.google.cloud.spanner.TimestampBound; import com.google.common.base.Stopwatch; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.api.metrics.DoubleHistogram; -import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -44,12 +45,14 @@ import io.opentelemetry.sdk.trace.export.SpanExporter; import io.opentelemetry.sdk.trace.samplers.Sampler; import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; class JavaClientRunner extends AbstractRunner { private final DatabaseId databaseId; @@ -61,12 +64,7 @@ class JavaClientRunner extends AbstractRunner { } @Override - public List execute( - TransactionType transactionType, - int numClients, - int numOperations, - int waitMillis, - boolean useMultiplexedSession) { + public List execute(BenchmarkingConfiguration configuration) { // setup open telemetry metrics and traces // setup open telemetry metrics and traces SpanExporter traceExporter = TraceExporter.createWithDefaultConfiguration(); @@ -93,7 +91,7 @@ public List execute( .build(); SessionPoolOptions sessionPoolOptions = SessionPoolOptionsHelper.setUseMultiplexedSession( - SessionPoolOptions.newBuilder(), useMultiplexedSession) + SessionPoolOptions.newBuilder(), configuration.isUseMultiplexSession()) .build(); SpannerOptions.enableOpenTelemetryMetrics(); SpannerOptions.enableOpenTelemetryTraces(); @@ -102,67 +100,71 @@ public List execute( .setOpenTelemetry(openTelemetry) .setProjectId(databaseId.getInstanceId().getProject()) .setSessionPoolOption(sessionPoolOptions) - .setHost(SERVER_URL) - .build(); - // Register query stats metric. - // This should be done once before start recording the data. - Meter meter = openTelemetry.getMeter("cloud.google.com/java"); - DoubleHistogram endToEndLatencies = - meter - .histogramBuilder("spanner/end_end_elapsed") - .setDescription("The execution of end to end latency") - .setUnit("ms") + .setHost(SERVER_URL_MAPPING.get(configuration.getEnvironment())) .build(); try (Spanner spanner = options.getService()) { DatabaseClient databaseClient = spanner.getDatabaseClient(databaseId); - List>> results = new ArrayList<>(numClients); - ExecutorService service = Executors.newFixedThreadPool(numClients); - for (int client = 0; client < numClients; client++) { - results.add( - service.submit( - () -> - runBenchmark( - databaseClient, - transactionType, - numOperations, - waitMillis, - endToEndLatencies))); + List>> results = new ArrayList<>(configuration.getNumOfClients()); + ExecutorService service = Executors.newFixedThreadPool(configuration.getNumOfClients()); + for (int client = 0; client < configuration.getNumOfClients(); client++) { + int clientId = client; + results.add(service.submit(() -> runBenchmark(databaseClient, clientId, configuration))); } - return collectResults(service, results, numClients, numOperations); + return collectResults(service, results, configuration); } catch (Throwable t) { throw SpannerExceptionFactory.asSpannerException(t); } } private List runBenchmark( - DatabaseClient databaseClient, - TransactionType transactionType, - int numOperations, - int waitMillis, - DoubleHistogram endToEndLatencies) { - List results = new ArrayList<>(numOperations); + DatabaseClient databaseClient, int clientId, BenchmarkingConfiguration configuration) { + List results = new ArrayList<>(); // Execute one query to make sure everything has been warmed up. - executeTransaction(databaseClient, transactionType, endToEndLatencies); + warmUp(databaseClient, clientId, configuration); + runBenchmark(databaseClient, clientId, configuration, results); + setBenchmarkingCompleted(clientId); + return results; + } - for (int i = 0; i < numOperations; i++) { + private void runBenchmark( + DatabaseClient databaseClient, + int clientId, + BenchmarkingConfiguration configuration, + List results) { + Instant endTime = Instant.now().plus(Duration.ofMinutes(configuration.getExecutionTime())); + initiateTimer(clientId, "Remaining execution time", endTime); + while (endTime.isAfter(Instant.now())) { try { - randomWait(waitMillis); - results.add(executeTransaction(databaseClient, transactionType, endToEndLatencies)); - incOperations(); + randomWait(configuration.getWaitBetweenRequests()); + results.add( + executeTransaction( + databaseClient, configuration.getTransactionType(), configuration.getStaleness())); } catch (InterruptedException interruptedException) { throw SpannerExceptionFactory.propagateInterrupt(interruptedException); } } - return results; + } + + private void warmUp( + DatabaseClient databaseClient, int clientId, BenchmarkingConfiguration configuration) { + Instant endTime = Instant.now().plus(Duration.ofMinutes(configuration.getWarmupTime())); + initiateTimer(clientId, "Remaining warmup time", endTime); + while (endTime.isAfter(Instant.now())) { + executeTransaction( + databaseClient, configuration.getTransactionType(), configuration.getStaleness()); + } } private Duration executeTransaction( - DatabaseClient client, TransactionType transactionType, DoubleHistogram endToEndLatencies) { + DatabaseClient client, TransactionType transactionType, int staleness) { Stopwatch watch = Stopwatch.createStarted(); switch (transactionType) { - case READ_ONLY_SINGLE_USE: - executeSingleUseReadOnlyTransaction(client); + case READ_ONLY_SINGLE_USE_READ: + executeSingleUseReadOnlyTransactionWithRead(client, staleness); + break; + case READ_ONLY_SINGLE_USE_QUERY: + executeSingleUseReadOnlyTransactionWithQuery(client, staleness); break; case READ_ONLY_MULTI_USE: executeMultiUseReadOnlyTransaction(client); @@ -171,13 +173,34 @@ private Duration executeTransaction( executeReadWriteTransaction(client); break; } - Duration elapsedTime = watch.elapsed(); - endToEndLatencies.record(elapsedTime.toMillis()); - return elapsedTime; + return watch.elapsed(); + } + + private void executeSingleUseReadOnlyTransactionWithRead(DatabaseClient client, int staleness) { + List columns = new ArrayList<>(); + int key = getRandomKey(); + columns.add("ID"); + try (ResultSet resultSet = + client + .singleUse(TimestampBound.ofExactStaleness(staleness, TimeUnit.SECONDS)) + .read(TABLE_NAME, KeySet.singleKey(Key.of(key)), columns)) { + while (resultSet.next()) { + for (int i = 0; i < resultSet.getColumnCount(); i++) { + if (resultSet.isNull(i)) { + numNullValues++; + } else { + numNonNullValues++; + } + } + } + } } - private void executeSingleUseReadOnlyTransaction(DatabaseClient client) { - try (ResultSet resultSet = client.singleUse().executeQuery(getRandomisedReadStatement())) { + private void executeSingleUseReadOnlyTransactionWithQuery(DatabaseClient client, int staleness) { + try (ResultSet resultSet = + client + .singleUse(TimestampBound.ofExactStaleness(staleness, TimeUnit.SECONDS)) + .executeQuery(getRandomisedReadStatement())) { while (resultSet.next()) { for (int i = 0; i < resultSet.getColumnCount(); i++) { if (resultSet.isNull(i)) { @@ -225,12 +248,14 @@ private void executeReadWriteTransaction(DatabaseClient client) { } static Statement getRandomisedReadStatement() { - int randomKey = ThreadLocalRandom.current().nextInt(TOTAL_RECORDS); - return Statement.newBuilder(SELECT_QUERY).bind(ID_COLUMN_NAME).to(randomKey).build(); + return Statement.newBuilder(SELECT_QUERY).bind(ID_COLUMN_NAME).to(getRandomKey()).build(); } static Statement getRandomisedUpdateStatement() { - int randomKey = ThreadLocalRandom.current().nextInt(TOTAL_RECORDS); - return Statement.newBuilder(UPDATE_QUERY).bind(ID_COLUMN_NAME).to(randomKey).build(); + return Statement.newBuilder(UPDATE_QUERY).bind(ID_COLUMN_NAME).to(getRandomKey()).build(); + } + + static int getRandomKey() { + return ThreadLocalRandom.current().nextInt(TOTAL_RECORDS); } } diff --git a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/LatencyBenchmark.java b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/LatencyBenchmark.java index 46083f1fee0..d3c2d71e955 100644 --- a/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/LatencyBenchmark.java +++ b/benchmarks/src/main/java/com/google/cloud/spanner/benchmark/LatencyBenchmark.java @@ -18,6 +18,7 @@ import com.google.api.core.InternalApi; import com.google.cloud.spanner.DatabaseId; +import com.google.cloud.spanner.benchmark.BenchmarkRunner.Environment; import com.google.cloud.spanner.benchmark.BenchmarkRunner.TransactionType; import com.google.common.annotations.VisibleForTesting; import java.time.Duration; @@ -65,10 +66,17 @@ private static CommandLine parseCommandLine(String[] args) throws ParseException options.addOption( "c", "clients", true, "The number of clients that will be executing queries in parallel."); options.addOption( - "o", - "operations", + "wu", + "warmupTime", true, - "The number of operations that each client will execute. Defaults to 1000."); + "Total warm up time before running actual benchmarking. Defaults to 7 minutes."); + options.addOption( + "et", + "executionTime", + true, + "Total execution time of the benchmarking. Defaults to 30 minutes."); + options.addOption( + "st", "staleness", true, "Total Staleness for Reads and Queries. Defaults to 15 seconds."); options.addOption( "w", "wait", @@ -78,12 +86,16 @@ private static CommandLine parseCommandLine(String[] args) throws ParseException + " second."); options.addOption( "t", - "transaction", + "transactionType", true, "The type of transaction to execute. Must be either READ_ONLY or READ_WRITE. Defaults to" + " READ_ONLY."); - options.addOption("m", "multiplexed", true, "Use multiplexed sessions. Defaults to false."); - options.addOption("w", "wait", true, "Wait time in millis. Defaults to zero."); + options.addOption( + "e", + "environment", + true, + "Spanner Environment. Must be either PROD or CLOUD_DEVEL. Default to CLOUD_DEVEL"); + options.addOption("m", "multiplexed", true, "Use multiplexed sessions. Defaults to true."); options.addOption("name", true, "Name of this test run"); CommandLineParser parser = new DefaultParser(); return parser.parse(options, args); @@ -97,34 +109,54 @@ private static CommandLine parseCommandLine(String[] args) throws ParseException public void run(CommandLine commandLine) { int clients = - commandLine.hasOption('c') ? Integer.parseInt(commandLine.getOptionValue('c')) : 16; - int operations = - commandLine.hasOption('o') ? Integer.parseInt(commandLine.getOptionValue('o')) : 1000; + commandLine.hasOption('c') ? Integer.parseInt(commandLine.getOptionValue('c')) : 1; + int executionTime = + commandLine.hasOption("et") ? Integer.parseInt(commandLine.getOptionValue("et")) : 30; + int warmUpTime = + commandLine.hasOption("wu") ? Integer.parseInt(commandLine.getOptionValue("wu")) : 7; int waitMillis = commandLine.hasOption('w') ? Integer.parseInt(commandLine.getOptionValue('w')) : 0; + int staleness = + commandLine.hasOption("st") ? Integer.parseInt(commandLine.getOptionValue("st")) : 15; TransactionType transactionType = commandLine.hasOption('t') ? TransactionType.valueOf(commandLine.getOptionValue('t').toUpperCase(Locale.ENGLISH)) - : TransactionType.READ_ONLY_SINGLE_USE; + : TransactionType.READ_ONLY_SINGLE_USE_QUERY; boolean useMultiplexedSession = - commandLine.hasOption('m') ? Boolean.parseBoolean(commandLine.getOptionValue('m')) : false; + !commandLine.hasOption('m') || Boolean.parseBoolean(commandLine.getOptionValue('m')); + Environment environment = + commandLine.hasOption('e') + ? Environment.valueOf(commandLine.getOptionValue('e').toUpperCase(Locale.ENGLISH)) + : Environment.CLOUD_DEVEL; + + BenchmarkingConfiguration configuration = + new BenchmarkingConfiguration() + .setDatabaseId(databaseId) + .setNumOfClients(clients) + .setExecutionTime(executionTime) + .setWarmupTime(warmUpTime) + .setStaleness(staleness) + .setTransactionType(transactionType) + .setUseMultiplexSession(useMultiplexedSession) + .setWaitBetweenRequests(waitMillis) + .setEnvironment(environment); System.out.println(); System.out.println("Running benchmark with the following options"); - System.out.printf("Database: %s\n", databaseId); - System.out.printf("Clients: %d\n", clients); - System.out.printf("Operations: %d\n", operations); - System.out.printf("Transaction type: %s\n", transactionType); - System.out.printf("Use Multiplexed Sessions: %s\n", useMultiplexedSession); - System.out.printf("Wait between queries: %dms\n", waitMillis); + System.out.printf("Database: %s\n", configuration.getDatabaseId()); + System.out.printf("Clients: %d\n", configuration.getNumOfClients()); + System.out.printf("Total Warm up Time: %d mins\n", configuration.getWarmupTime()); + System.out.printf("Total Execution Time: %d mins\n", configuration.getExecutionTime()); + System.out.printf("Staleness: %d secs\n", configuration.getStaleness()); + System.out.printf("Transaction type: %s\n", configuration.getTransactionType()); + System.out.printf("Use Multiplexed Sessions: %s\n", configuration.isUseMultiplexSession()); + System.out.printf("Wait between requests: %dms\n", configuration.getWaitBetweenRequests()); List javaClientResults = null; System.out.println(); System.out.println("Running benchmark for Java Client Library"); - JavaClientRunner javaClientRunner = new JavaClientRunner(databaseId); - javaClientResults = - javaClientRunner.execute( - transactionType, clients, operations, waitMillis, useMultiplexedSession); + JavaClientRunner javaClientRunner = new JavaClientRunner(configuration.getDatabaseId()); + javaClientResults = javaClientRunner.execute(configuration); printResults("Java Client Library", javaClientResults); }