I am using Google Caliper (latest master code) to benchmark four pieces of code across two dimensions. For example, the following benchmark methods:
@Benchmark mechanismOneBreadth(...)
@Benchmark mechanismOneDepth(...)
@Benchmark mechanismTwoBreadth(...)
@Benchmark mechanismTwoDepth(...)
What I would like to do is annotate each benchmark with some additional dimensions for display/manipulation on the results app, so that I can compare one-depth with one-breadth, but also compare one-depth with two-depth and one-breadth with two-breadth. For example:
@Benchmark @Dimensions({"one", "breadth"}) mechanismOneBreadth(...)
@Benchmark @Dimensions({"one", "depth"}) mechanismOneDepth(...)
@Benchmark @Dimensions({"two", "breadth"}) mechanismTwoBreadth(...)
@Benchmark @Dimensions({"two", "depth"}) mechanismTwoDepth(...)
The dimensions specified would act very much like parameters for display on the UI, but I can't use parameters because the called code is different in each case. Is there a way to do this with the current version of Caliper?
The dimensions specified would act very much like parameters for display on the UI, but I can't use parameters because the called code is different in each case.
But you can (I do it quite often). Just write a single method testing the params and dispatching to the method you want. The overhead is totally negligible as the whole loop happens inside, so why not?
PS: If some combination makes no sense, you can use throw new SkipThisScenarioException
, assuming you're using current version (I'm using the one from git, no idea what's been released).