Created
February 21, 2013 21:30
-
-
Save spullara/5008433 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MappingJsonFactory jf = new MappingJsonFactory(); | |
AtomicInteger lines = new AtomicInteger(0); | |
for (int i = 0; i < 10; i++) { | |
long start = System.currentTimeMillis(); | |
Stream<String> br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(args[0])), "UTF-8")).lines(); | |
if (i % 2 == 0) { | |
System.out.print("parallel: "); | |
br = br.parallel(); | |
} else { | |
System.out.print("serial: "); | |
} | |
br.map((line) -> { | |
try { | |
return (JsonNode) jf.createParser(line).readValueAsTree(); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
}).forEach((o) -> lines.incrementAndGet()); | |
System.out.println(lines + " " + (System.currentTimeMillis() - start)); | |
lines.set(0); | |
} | |
} |
Author
spullara
commented
Feb 21, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment