Skip to content

Commit

Permalink
Make measurement not output numbers as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
easbar committed Oct 10, 2019
1 parent 2f70d70 commit ee02bc1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions tools/src/main/java/com/graphhopper/tools/Measurement.java
Expand Up @@ -56,7 +56,7 @@
*/
public class Measurement {
private static final Logger logger = LoggerFactory.getLogger(Measurement.class);
private final Map<String, String> properties = new TreeMap<>();
private final Map<String, Object> properties = new TreeMap<>();
private long seed;
private int maxNode;

Expand Down Expand Up @@ -578,13 +578,12 @@ void print(String prefix, MiniPerfTest perf) {
}

void put(String key, Object val) {
// convert object to string to make serialization possible
properties.put(key, "" + val);
properties.put(key, val);
}

private void storeJson(String graphLocation, String jsonLocation) {
logger.info("storing measurement json in " + jsonLocation);
String gitInfo = properties.get("gh.gitinfo");
String gitInfo = properties.get("gh.gitinfo").toString();
if (gitInfo == null) {
logger.error("gitinfo not available, writing properties instead of json");
storeProperties(graphLocation, jsonLocation);
Expand Down Expand Up @@ -615,10 +614,10 @@ private void storeProperties(String graphLocation, String propLocation) {
try (FileWriter fileWriter = new FileWriter(propLocation)) {
String comment = "measurement finish, " + new Date().toString() + ", " + Constants.BUILD_DATE;
fileWriter.append("#" + comment + "\n");
for (Entry<String, String> e : properties.entrySet()) {
for (Entry<String, Object> e : properties.entrySet()) {
fileWriter.append(e.getKey());
fileWriter.append("=");
fileWriter.append(e.getValue());
fileWriter.append(e.getValue().toString());
fileWriter.append("\n");
}
fileWriter.flush();
Expand Down Expand Up @@ -693,10 +692,8 @@ private String getSummaryLogLine(String[] properties, String propLocation) {
}

private String getFormattedProperty(String property) {
String result = properties.get(property);
if (result == null) {
result = "missing";
}
Object resultObj = properties.get(property);
String result = resultObj == null ? "missing" : resultObj.toString();
// limit number of decimal places for floating point numbers
try {
double doubleValue = Double.parseDouble(result.trim());
Expand Down

0 comments on commit ee02bc1

Please sign in to comment.