I wish to measure the time taken to instantiate an object in java. I can't use the profiling tool in Eclipse as it won't work for me - I get a nasty error. Is it possible to measure the time manually? I have the following
for (int i=0; i<1000; i++) {
long endTime;
long startTime = System.nanoTime();
MyObj obj = new MyObj();
endTime = System.nanoTime();
System.out.println("Instantiation time: " + (endTime - startTime));
}
The problem with this however is that it just returns 0 all the time. Any suggestions?