// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class CloneSpeed {
    private final static int N = 10000;
    private final static int REP = 100000;
    public static void main(String[] args) {
        int[] a = new int[N];
        long t1 = System.currentTimeMillis();
        for(int i = 0; i < REP; i++) {
            int[] b = (int[])a.clone();
        }
        long t2 = System.currentTimeMillis();
        System.out.println("clone: " + (t2-t1));
        long t3 = System.currentTimeMillis();
        for(int i = 0; i < REP; i++) {
            int[] b = new int[a.length];
            System.arraycopy(a, 0, b, 0, a.length);
        }
        long t4 = System.currentTimeMillis();
        System.out.println("arraycopy: " + (t4-t3));
    }
}
