javamethodsprofilervisualvmcpu-time

VisualVM Profiler: How to test CPU Time for a method with varying parameter sizes?


Suppose I have a method that can take in a parameter is size n (Like an array with size n); is it possible to investigate the CPU Times for the method with varying array sizes in an automated manner using VisualVM's Profiler?

Currently I only know how to investigate a particular running instance, and even if I use a loop to repeat the method with increasing n, VisualVM's profiler can only tell me the accumulative CPU Time. Ideally, I will be able to plot a graph of CPU Time vs n, where n is the size of the parameter I pass into the method. Is this possible with VisualVM?


Solution

  • The only tool I know that has this functionality out of the box is JProfiler with its Complexity analysis:

    enter image description here

    You can configure a method and a script that calculates a number from its parameters (the complexity), in your case the script would just return the parameter itself.

    Disclaimer: My company develops JProfiler