Measuring class loading time

Kasper Nielsen kasperni at gmail.com
Tue Mar 14 20:44:41 UTC 2023


Hi,

I'm contemplating converting some class generation functionality to use indy
to avoid some startup latency. However, I would really like to get an idea
of any time savings first and I'm not completely sure about the best strategy
for measuring this.

Would measuring Lookup.defineHiddenClass with pre-generated byte arrays be
fine? Or is there a significant overhead of setting up a class loader for
just a single class compared to using the system class loader to load classes
at application startup?

An alternative would be to create a class loader and load 100 similar classes
but with different names to amortize the cost of setting up a class loader.

Also, are there any pitfalls with how this might interact with the VM I should
be aware of? I feel like there may be strange interactions that make this
difficult to measure in a reliable way.

Thanks,
  Kasper


More information about the jmh-dev mailing list