0

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?

Raman
  • 17,606
  • 5
  • 95
  • 112

1 Answers1

1

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).

maaartinus
  • 44,714
  • 32
  • 161
  • 320
  • Yes I started to do this but it got kind of complex... my question was simplified a bit. – Raman Oct 18 '14 at 20:27
  • @Raman I'm afraid, that's the only way. The only problem with it, I ever had, was that some combinations make no sense. I guess, you'd need to add some boring details to your question to get more information. – maaartinus Oct 18 '14 at 20:35
  • 1
    Thanks, I was able to simplify my problem space enough to make this feasible. I'm accepting your answer. – Raman Oct 22 '14 at 17:35