5

I want to profile how a method's execution time and memory consumption scale depending on the method's parameters. So far, I have come up with testing the method via JUnit and running several tests for different sets of parameters (e.g. using JUnit Theories). In order to abstract from overhead due to setting up tests etc. the time is calculated by a difference in System.currentTimeMillis right before and after the step I am interested in. This seems somewhat hacky, is there a more natural way to do this?

I would furthermore like to see how memory consumption behaves with different parameters. JVisualVM comes to mind, but is there a more elegant way to automatically get what I want?

0

1 Answer 1

4

I suggest you using JMH java benchmark framework.

JMH is a Java harness for building, running, and analysing nano/micro/milli/macro benchmarks written in Java and other languages targetting the JVM.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't think it covers the memory aspect of the question, does it?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.