views:

104

answers:

1

How can I see how much time it took for the code to run in InteliJ?

+2  A: 

I don't think you can with Intellij, you either have to use a profiler like Yourkit to profile the code or use some primitive benchmarks using System.currentTimeInMillis(). Alternatively you can use Apache Commons StopWatch to do some benchmarking:

StopWatch stopwatch = new StopWatch();
stopwatch.start();
... some code...
stopwatch.stop();
long timeTaken = stopWatch.getTime()

http://commons.apache.org/lang/api/org/apache/commons/lang/time/StopWatch.html

EDIT: There is a plugin available for Intellij that uses VisualVM to do profiling, you could install this as another alternative.

http://plugins.intellij.net/plugin/?id=3749

Jon
Thanks, the VisualVM plugin does the job. Also, it seems that YourKit is a shareware that even for the "free evolution" requires registration, just an FYI for future readers.
Xenorose
"free evolution" - one of the funniest spelling mistakes :)
ripper234
Hehe, opps!Happens when you don't think enough about what it is you're writing, but just let it come out automatically, or maybe it was just getting too late and close to sleeping time.
Xenorose