Created
October 19, 2012 16:07
-
-
Save mitio/3919061 to your computer and use it in GitHub Desktop.
Tests for copying byte[] arrays
This file contains hidden or 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
public class ByteArrayCopyTest { | |
private static long timeMark; | |
public static void main(String[] args) { | |
byte[] source = new byte[1000000]; | |
byte[] target = new byte[1000000]; | |
start(); | |
for (int n = 0; n < 10000; n++) { | |
// System.arraycopy(source, 0, target, 0, source.length); | |
for (int i = 0; i < source.length; i++) { | |
target[i] = source[i]; | |
} | |
} | |
endAndReport(); | |
} | |
private static void start() { | |
timeMark = System.currentTimeMillis(); | |
} | |
private static void endAndReport() { | |
long now = System.currentTimeMillis(); | |
System.out.println("Execution time: " + (now - timeMark) + " ms"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment