Skip to content

Instantly share code, notes, and snippets.

@henryr
Created January 9, 2014 23:20
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 henryr/8344024 to your computer and use it in GitHub Desktop.
Save henryr/8344024 to your computer and use it in GitHub Desktop.
import java.io.ByteArrayOutputStream;
public class TestByteArray {
static byte[] chunk = new byte[1024 * 1024];
public static void main(String[] args) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int numChunks = 2 * 1024 * 1024;
for (int i = 0; i < numChunks; ++i) {
long start = System.currentTimeMillis();
baos.write(chunk, 0, chunk.length);
long end = System.currentTimeMillis();
System.out.println("Chunk " + i + " of " + numChunks + " took: " + ((end - start) / 1000.0) + "s, total written: " + (i * chunk.length) + " bytes");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment