@Benchmark
    public String testCachePerformance() {
        counter++;
        int index = (int) (counter % DISTINCT_KEYS);
        String hashkey = keys[index];
        lruCache.put(hashkey, values[index]);
        return lruCache.get(hashkey);
    }
This is a simple example of a JMH benchmark.

The sample code provided by the JMH project is a great place to start learning how to write correct benchmarks:
http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
jmh-benchmarks/src/main/java/org/apache/kafka/jmh/cache/LRUCacheBenchmark.java