Created
January 9, 2014 23:20
-
-
Save henryr/8344024 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
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