2

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?

Ymi
  • 609
  • 6
  • 18
  • What do you mean with the size of a parameter? The amount of memory it consumes? – pveentjer Sep 12 '21 at 02:52
  • for example, run a method with a dataset (for example an array) with size=1, size=2, size=3, and so on... afterwards I need a graph of CPUTime against size of dataset – Ymi Sep 12 '21 at 03:10
  • 1
    I'm no VisualVM profiler expert (there are better alterntives). But I don't think it can make a distinction based on array size. If you want to get some performance impressions, just write a JMH microbenchmark and run it with various array sizes and check how much it impacts performance. – pveentjer Sep 12 '21 at 03:17

1 Answers1

3

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

Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102