-- Leo's gemini proxy

-- Connecting to republic.circumlunar.space:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Profile a Java unit test (very quickly, with no external tools)


I have a unit test that is running slowly, and I want a quick view of what is happening.


I can get a nice overview of where the code spends its time by adding this to the JVM arguments:


-agentlib:hprof=cpu=samples,lineno=y,depth=3,file=hprof.samples.txt

and running the test as normal.


Now I can look at the file that was created, hprof.samples.txt, and looking at the bottom section I can see how much time is spent in each method.


This worked for me within IntelliJ IDEA community edition by clicking "Run" then "Edit Configurations" and adding the above code to "VM options" for my test.


It should also work in Gradle by editing gradle.properties and adding something like this:


org.gradle.jvmargs=-agentlib:hprof=cpu=samples,lineno=y,depth=3,file=hprof.samples.txt

and should also work in Maven. In fact, I found this information in this stackoverflow question: How do you run maven unit tests with hprof?.


Originally posted at 2020-11-23 11:03:02+00:00. Automatically generated from the original post : apologies for the errors introduced.


How do you run maven unit tests with hprof?

original post

-- Response ended

-- Page fetched on Sun May 19 07:58:34 2024