How to measure allocation rate with jmh?

3.1k Views Asked by At

JMH seems like it does most caliper features as well or better than caliper, but I couldn't figure out how to measure allocation rate, which is in general useful to be able to look at in a microbenchmark. Is JMH the wrong tool to measure allocation rate?

1

There are 1 best solutions below

1
On BEST ANSWER

There is no accurate allocation rate measurement in JMH. This is a job for profiler, like Java Mission Control. In JMH, you can roughly estimate the allocation pressure by observing the GC counts via the MXBeans. This is wrapped by JMH profilers, e.g. -prof gc. Use -lprof to get the list of embedded profilers.