added buffering to boost performance

This commit is contained in:
2019-09-28 09:41:21 +01:00
parent 428c4a68d5
commit 51a7e8ffb0
5 changed files with 42 additions and 43 deletions

View File

@@ -30,7 +30,7 @@ public class Main {
@SneakyThrows
private static InputStream extractTestData() {
return new XZInputStream(new BufferedInputStream(Main.class.getResourceAsStream("/citylots.json.xz")));
return new XZInputStream(Main.class.getResourceAsStream("/citylots.json.xz"));
}
@SneakyThrows
@@ -62,7 +62,7 @@ public class Main {
for (int j = 0; j < 2; j++) {
chr.reset();
for (int i = 0; i < loops; i++) {
Value value = new JSONParser().parse(smallTestData());
Value value = new JSONParser().parse(new BufferedReader(new InputStreamReader(smallTestData())));
}
}
worthTime = chr.stop(Chronometer.TimeUnit.MILLISECOND);
@@ -98,7 +98,7 @@ public class Main {
try (InputStream is = extractTestData()) {
chr.reset();
ObjectMapper om = new ObjectMapper();
om.readTree(is);
om.readTree(new InputStreamReader(is));
double elapsedTime = chr.stop(Chronometer.TimeUnit.SECOND);
System.out.printf("Jackson time: %8s sec\n", String.format("%.3f", elapsedTime));
}