Isuru Gunawardana
Isuru Gunawardana

Reputation: 2887

Run Micro-benchmark in application servers [JMH]

I read about JMH and tried the samples provided.

What I am trying to do is measure the stats of following scenario,

[ 1] client order -> [2] server -> [3] start processing the order -> [4] processed the order successfully and ready to send -> [5] client receive the response

I could successfully done [ 1] to [5] scenario. There I am calling my client from @Benchmark annotated method using benchmark.jar

Now I am stuck at measuring stats from [2] to [4] which represents the server side processing. Should I do this by annotating server side methods? If so how can I call those method in a way that to get the benchmark stats?

Documentation says The recommended way to run a JMH benchmark is to use Maven to setup a standalone project that depends on the jar files of your application. Does this mean the scenario I'm trying is not possible using JMH?

Update: Is there a way to call @Benchmark annotated methods via rmi calls?

Upvotes: 0

Views: 733

Answers (2)

Anil Punia
Anil Punia

Reputation: 37

You can use monitoring tools like graphite for your use case.

Upvotes: 1

Aleksey Shipilev
Aleksey Shipilev

Reputation: 18847

@Benchmark Javadoc says:

 * <p>{@link Benchmark} demarcates the benchmark payload, and JMH treats it specifically
 * as the wrapper which contains the benchmark code. In order to run the benchmark reliably,
 * JMH enforces a few stringent properties for these wrapper methods, including, but not
 * limited to:</p>

@Benchmark is the annotation demarcating the piece of code JMH should treat as benchmark body. It is not a magic annotation which measures any given method elsewhere in the program. And, you are not supposed to call @Benchmark methods on your own.

What you want is not benchmark, it's a tracing/monitoring/profiling solution which can instrument and account all the stages the request gets through. JMH is not such a solution, you should look elsewhere.

Upvotes: 2

Related Questions