Since System.arraycopy() and clone() does only shallow copying, I wonder if this approach would work for doing a deep copy.
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
long x=System.nanoTime();
oos.writeObject(fromArray);
oos.flush();
ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bin);
Object o=ois.readObject();
double timeTaken= (System.nanoTime()-x)/1000000000.0;
1) Will the variable, timeTaken give me the actual time to do a deep copy?
2) If I pass data say an array of size 1MB like
byte[] fromArray = new byte[1024*1024];
and calculate throughput in Mb/sec like,
double throughput=1/timeTaken;
Will it be reasonable to consider this as a memory benchmarking throughput?