Time a function: Difference between revisions

Content deleted Content added
Lanky79 (talk | contribs)
No edit summary
Reilas (talk | contribs)
Line 1,493:
 
=={{header|Java}}==
If you're looking for a quick way to calculate the duration of a few lines of code you can utilize the <code>System.currentTimeMillis</code> method.
<syntaxhighlight lang="java">
long start = System.currentTimeMillis();
/* code you want to time, here */
long duration = System.currentTimeMillis() - start;
</syntaxhighlight>
<br />
{{works with|Java|1.5+}}
<syntaxhighlight lang="java">import java.lang.management.ManagementFactory;