Search in sources :

Example 1 with Element

use of com.google.common.collect.CollectionBenchmarkSampleData.Element in project guava by google.

the class MapBenchmark method iterateWithKeySetAndGet.

@Benchmark
boolean iterateWithKeySetAndGet(int reps) {
    Map<Element, Element> map = mapToTest;
    boolean dummy = false;
    for (int i = 0; i < reps; i++) {
        for (Element key : map.keySet()) {
            Element value = map.get(key);
            dummy ^= key != value;
        }
    }
    return dummy;
}
Also used : Element(com.google.common.collect.CollectionBenchmarkSampleData.Element) Benchmark(com.google.caliper.Benchmark)

Example 2 with Element

use of com.google.common.collect.CollectionBenchmarkSampleData.Element in project guava by google.

the class MapBenchmark method iterateValuesAndGet.

@Benchmark
boolean iterateValuesAndGet(int reps) {
    Map<Element, Element> map = mapToTest;
    boolean dummy = false;
    for (int i = 0; i < reps; i++) {
        for (Element key : map.values()) {
            // This normally wouldn't make sense, but because our keys are our values it kind of does
            Element value = map.get(key);
            dummy ^= key != value;
        }
    }
    return dummy;
}
Also used : Element(com.google.common.collect.CollectionBenchmarkSampleData.Element) Benchmark(com.google.caliper.Benchmark)

Aggregations

Benchmark (com.google.caliper.Benchmark)2 Element (com.google.common.collect.CollectionBenchmarkSampleData.Element)2