Created
December 11, 2017 12:28
-
-
Save iobee/d0a0f1b19337aa17dfc638d78ed9662c to your computer and use it in GitHub Desktop.
testJavaWriteFilePerformance
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
char[] chars = new char[100*1024*1024]; | |
Arrays.fill(chars, 'A'); | |
String text = new String(chars); | |
long start = System.nanoTime(); | |
BufferedWriter bw = new BufferedWriter(new FileWriter("/tmp/a.txt")); | |
bw.write(text); | |
bw.close(); | |
long time = System.nanoTime() - start; | |
System.out.println("Wrote " + chars.length*1000L/time+" MB/s."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment