Skip to content

Instantly share code, notes, and snippets.

@iobee
Created December 11, 2017 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iobee/d0a0f1b19337aa17dfc638d78ed9662c to your computer and use it in GitHub Desktop.
Save iobee/d0a0f1b19337aa17dfc638d78ed9662c to your computer and use it in GitHub Desktop.
testJavaWriteFilePerformance
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