Closed blerer closed 1 year ago
After looking into it, we decided to stay away from caching as it has some impact on memory that are difficult to plan for.
The final changes are:
INSTRUMENTATION_AND_SPECIFICATION
strategy has been introduced. It improves significantly the speed of array measurements compare to the INSTRUMENTATION
strategy, for java version < 17.Measurable
interface has been introduce that allow user to avoid the cost of reflection and provide a more controlled crawling.
By default Jamm should provided correct measurements while being as simple as possible to use. Nevertheless for some usecases people might wish to make some trade off to get better faster measurements out of Jamm.
There are different areas on which user could play to get better performance:
Eliminating the cost of reflection
The cost of reflection could be eliminated by providing a way for classes to add their children objects directly to the stack instead of having to rely on reflection. The drawback of this approach is that it push the responsibility to the user to ensure that all children are taken into account.
Caching measurement
Jamm should allow users to define a simple caching strategy for measurements
Using the more efficient measurements even if the belongs to different strategies
The INSTRUMENTATION strategy outperform other strategies for non array measurements but other strategies are more performant for array measurements. As array measurements do not suffer from correctness issue we could create a new strategy that use Instrumentation to measure non array objects and the SPEC approach for array objects