requests-simulator

.parallel() on reducer

8/28/2019 1:51:06 PM

Details

diff --git a/src/main/java/br/ufrgs/inf/prosoft/requestssimulator/Reducer.java b/src/main/java/br/ufrgs/inf/prosoft/requestssimulator/Reducer.java
index 7943254..1c34e0e 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/requestssimulator/Reducer.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/requestssimulator/Reducer.java
@@ -29,14 +29,14 @@ public class Reducer {
     public static void reduce(String throughputPath, String reducePath, String prefix) {
         try (Stream<String> lines = Files.lines(Paths.get(throughputPath))) {
             JsonParser jsonParser = new JsonParser();
-            List<Long> seconds
-                    = lines.map(line -> jsonParser.parse(line).getAsJsonObject().get("time").getAsLong() / 1000)
-                            .collect(Collectors.toList());
+            List<Long> seconds = lines.parallel()
+                    .map(line -> jsonParser.parse(line).getAsJsonObject().get("time").getAsLong() / 1000)
+                    .collect(Collectors.toList());
 
-            Long min = seconds.stream().min(Long::compare).get();
-            Long max = seconds.stream().max(Long::compare).get();
+            Long min = seconds.stream().parallel().min(Long::compare).get();
+            Long max = seconds.stream().parallel().max(Long::compare).get();
 
-            Map<Long, Long> secondHasRequests = seconds.stream().map(time -> time - min)
+            Map<Long, Long> secondHasRequests = seconds.stream().parallel().map(time -> time - min)
                     .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
 
             max -= min;