advice on usage of jmh
Jochen Theodorou
blackdrag at gmx.org
Thu Sep 17 13:09:59 UTC 2015
Am 16.09.2015 22:49, schrieb Aleksey Shipilev:
> Hi,
>
> These questions should normally go to StackOverflow -- those guys even
> have a "jmh" tag, and many power JMH users are answering questions there.
will do so in the future
> On 09/16/2015 09:34 PM, Jochen Theodorou wrote:
>> My problem is, that when ever I try to rewrite this into something using
>> JMH the code size explodes. Instead of a single generic method for
>> containsKey I end up with one for each map type, plus..
>
> I can't see a problem with selecting an implementation, if they all
> implement the same interface, e.g:
>
> http://hg.openjdk.java.net/code-tools/jmh/file/f2d57d49d36b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java#l71
>
> The same thing could be done for selecting a dataset you are walking.
thanks, that's neat
>> then I thought I could use enums to make this more easy, but then I
>> found out that @Param does not allow me to select the enum values I
>> want to go through.
>
> Using enums may be cleaner and more resilient against typos. What does
> it mean "@Param does not allow to select the enum values"? This works
> perfectly well:
>
> @State(Scope.Thread)
> public class EnumBenchTest {
>
> public enum MyMode {
> MODE1,
> MODE2
> }
>
> @Param({"MODE1"})
> private MyMode mode;
>
> @Benchmark
> public void test() {
> // intentionally left blank
> }
> }
ah... ok, I misunderstood something.. thanks
bye Jochen
--
Jochen "blackdrag" Theodorou
blog: http://blackdragsview.blogspot.com/
More information about the jmh-dev
mailing list