Measure object instantiation
<p>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 </p>

<pre><code>    for (int i=0; i&lt;1000; i++) {
        long endTime;
        long startTime = System.nanoTime();
        MyObj obj = new MyObj();
        endTime = System.nanoTime();
        System.out.println("Instantiation time: " + (endTime - startTime));
    }
</code></pre>

<p>The problem with this however is that it just returns 0 all the time. Any suggestions?</p>
