Skip to content

Commit

Permalink
Use Optional.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Oct 19, 2023
1 parent 07d7aff commit b60cb25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javababushka.benchmarks.jedis.JedisClient;
Expand Down Expand Up @@ -86,7 +87,7 @@ private static RunConfiguration verifyOptions(CommandLine line) throws ParseExce
}

if (line.hasOption("resultsFile")) {
runConfiguration.resultsFile = line.getOptionValue("resultsFile");
runConfiguration.resultsFile = Optional.ofNullable(line.getOptionValue("resultsFile"));
}

if (line.hasOption("dataSize")) {
Expand Down Expand Up @@ -195,7 +196,7 @@ public boolean isEqual(String other) {
public static class RunConfiguration {
public String configuration;
public int dataSize;
public String resultsFile;
public Optional<String> resultsFile;
public List<Integer> concurrentTasks;
public ClientName[] clients;
public String host;
Expand All @@ -206,7 +207,7 @@ public static class RunConfiguration {

public RunConfiguration() {
configuration = "Release";
resultsFile = null;
resultsFile = Optional.empty();
dataSize = 20;
concurrentTasks = List.of(10, 100);
clients =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ public static void testClientSetGet(
});

var calculatedResults = calculateResults(actionResults);
if (config.resultsFile != null) {
if (config.resultsFile.isPresent()) {
JsonWriter.WriteJson(
calculatedResults,
config.resultsFile,
config.resultsFile.get(),
config.dataSize,
clientCreator.get().getName(),
clientNum,
clientCount,
concurrentNum,
iterationCounter.get() * 1e9 / (System.nanoTime() - started));
}
Expand Down

0 comments on commit b60cb25

Please sign in to comment.