I'm trying to figure out why unit tests are taking seconds to run instead of milliseconds. This is a significant issue because over ~300 test classes, this results in 20 minutes. My hope is to use a performance analyzer (like java HPROF) with my maven unit tests. I would then analyze the hprof output on my own.
I added the below argline config to my surefire plugin block
<configuration>
<forkMode>never</forkMode>
<argLine>
-agentlib:hprof=cpu=samples,lineno=y,depth=3,file=hprof.samples.txt
</argLine>
...
<configuration>
You must not fork JVMs. All tests have to reuse the same jvm for this to work.
That generates an hprof file (see: https://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html ). That gives you hints on what part of the code is slowing things down. In my case it was a combination of reuseFork=never and class loading.