Java 类com.google.common.collect.CollectionBenchmarkSampleData.Element 实例源码

项目:guava-mock    文件:MapBenchmark.java   
@Benchmark boolean get(int reps) {
  // Paranoia: acting on hearsay that accessing fields might be slow
  // Should write a benchmark to test that!
  Map<Element, Element> map = mapToTest;
  Element[] queries = this.queries;

  // Allows us to use & instead of %, acting on hearsay that division
  // operators (/%) are disproportionately expensive; should test this too!
  int mask = queries.length - 1;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    dummy ^= map.get(queries[i & mask]) != null;
  }
  return dummy;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Benchmark boolean get(int reps) {
  // Paranoia: acting on hearsay that accessing fields might be slow
  // Should write a benchmark to test that!
  Map<Element, Element> map = mapToTest;
  Element[] queries = this.queries;

  // Allows us to use & instead of %, acting on hearsay that division
  // operators (/%) are disproportionately expensive; should test this too!
  int mask = queries.length - 1;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    dummy ^= map.get(queries[i & mask]) != null;
  }
  return dummy;
}
项目:guava-libraries    文件:MapBenchmark.java   
@Benchmark boolean get(int reps) {
  // Paranoia: acting on hearsay that accessing fields might be slow
  // Should write a benchmark to test that!
  Map<Element, Element> map = mapToTest;
  Element[] queries = this.queries;

  // Allows us to use & instead of %, acting on hearsay that division
  // operators (/%) are disproportionately expensive; should test this too!
  int mask = queries.length - 1;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    dummy ^= map.get(queries[i & mask]) != null;
  }
  return dummy;
}
项目:guava    文件:MapBenchmark.java   
@Benchmark
boolean get(int reps) {
  // Paranoia: acting on hearsay that accessing fields might be slow
  // Should write a benchmark to test that!
  Map<Element, Element> map = mapToTest;
  Element[] queries = this.queries;

  // Allows us to use & instead of %, acting on hearsay that division
  // operators (/%) are disproportionately expensive; should test this too!
  int mask = queries.length - 1;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    dummy ^= map.get(queries[i & mask]) != null;
  }
  return dummy;
}
项目:guava    文件:MapBenchmark.java   
@Benchmark
boolean get(int reps) {
  // Paranoia: acting on hearsay that accessing fields might be slow
  // Should write a benchmark to test that!
  Map<Element, Element> map = mapToTest;
  Element[] queries = this.queries;

  // Allows us to use & instead of %, acting on hearsay that division
  // operators (/%) are disproportionately expensive; should test this too!
  int mask = queries.length - 1;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    dummy ^= map.get(queries[i & mask]) != null;
  }
  return dummy;
}
项目:guava-mock    文件:SetIterationBenchmark.java   
@Benchmark int iteration(int reps) {
  int x = 0;

  for (int i = 0; i < reps; i++) {
    for (Element y : setToTest) {
      x ^= System.identityHashCode(y);
    }
  }
  return x;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = Maps.newHashMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = Maps.newLinkedHashMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = Maps.newTreeMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = new ConcurrentSkipListMap<Element, Element>();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map =
      new ConcurrentHashMap<Element, Element>(keys.size(), 0.75f, 1);
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map =
      new ConcurrentHashMap<Element, Element>(keys.size(), 0.75f, 16);
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = new MapMaker()
      .concurrencyLevel(1)
      .makeMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = new MapMaker()
      .concurrencyLevel(16)
      .makeMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  ImmutableMap.Builder<Element, Element> builder = ImmutableMap.builder();
  for (Element element : keys) {
    builder.put(element, element);
  }
  return builder.build();
}
项目:guava-mock    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  ImmutableSortedMap.Builder<Element, Element> builder =
      ImmutableSortedMap.naturalOrder();
  for (Element element : keys) {
    builder.put(element, element);
  }
  return builder.build();
}
项目:guava-mock    文件:MapBenchmark.java   
@BeforeExperiment void setUp() {
  CollectionBenchmarkSampleData sampleData =
      new CollectionBenchmarkSampleData(
          isUserTypeFast, random, hitRate, size);

  if (sortedData) {
    List<Element> valueList = newArrayList(sampleData.getValuesInSet());
    Collections.sort(valueList);
    values = valueList;
  } else {
    values = sampleData.getValuesInSet();
  }
  this.mapToTest = impl.create(values);
  this.queries = sampleData.getQueries();
}
项目:guava-mock    文件:MapBenchmark.java   
@Benchmark boolean iterateWithEntrySet(int reps) {
  Map<Element, Element> map = mapToTest;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    for (Map.Entry<Element, Element> entry : map.entrySet()) {
      dummy ^= entry.getKey() != entry.getValue();
    }
  }
  return dummy;
}
项目:guava-mock    文件:MapBenchmark.java   
@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;

}
项目:guava-mock    文件:MapBenchmark.java   
@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;

}
项目:guava-mock    文件:SetContainsBenchmark.java   
@BeforeExperiment void setUp() {
  CollectionBenchmarkSampleData sampleData =
      new CollectionBenchmarkSampleData(
          isUserTypeFast, random, hitRate, size);

  this.setToTest = (Set<Element>)impl.create(sampleData.getValuesInSet());
  this.queries = sampleData.getQueries();
}
项目:guava-mock    文件:SetContainsBenchmark.java   
@Benchmark boolean contains(int reps) {
  // Paranoia: acting on hearsay that accessing fields might be slow
  // Should write a benchmark to test that!
  Set<Element> set = setToTest;
  Element[] queries = this.queries;

  int mask = queries.length - 1;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    dummy ^= set.contains(queries[i & mask]);
  }
  return dummy;
}
项目:googles-monorepo-demo    文件:SetIterationBenchmark.java   
@Benchmark int iteration(int reps) {
  int x = 0;

  for (int i = 0; i < reps; i++) {
    for (Element y : setToTest) {
      x ^= System.identityHashCode(y);
    }
  }
  return x;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = Maps.newHashMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = Maps.newLinkedHashMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = Maps.newTreeMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = new ConcurrentSkipListMap<Element, Element>();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map =
      new ConcurrentHashMap<Element, Element>(keys.size(), 0.75f, 1);
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map =
      new ConcurrentHashMap<Element, Element>(keys.size(), 0.75f, 16);
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = new MapMaker()
      .concurrencyLevel(1)
      .makeMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = new MapMaker()
      .concurrencyLevel(16)
      .makeMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  ImmutableMap.Builder<Element, Element> builder = ImmutableMap.builder();
  for (Element element : keys) {
    builder.put(element, element);
  }
  return builder.build();
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  ImmutableSortedMap.Builder<Element, Element> builder =
      ImmutableSortedMap.naturalOrder();
  for (Element element : keys) {
    builder.put(element, element);
  }
  return builder.build();
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@BeforeExperiment void setUp() {
  CollectionBenchmarkSampleData sampleData =
      new CollectionBenchmarkSampleData(
          isUserTypeFast, random, hitRate, size);

  if (sortedData) {
    List<Element> valueList = newArrayList(sampleData.getValuesInSet());
    Collections.sort(valueList);
    values = valueList;
  } else {
    values = sampleData.getValuesInSet();
  }
  this.mapToTest = impl.create(values);
  this.queries = sampleData.getQueries();
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@Benchmark boolean iterateWithEntrySet(int reps) {
  Map<Element, Element> map = mapToTest;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    for (Map.Entry<Element, Element> entry : map.entrySet()) {
      dummy ^= entry.getKey() != entry.getValue();
    }
  }
  return dummy;
}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@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;

}
项目:googles-monorepo-demo    文件:MapBenchmark.java   
@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;

}
项目:googles-monorepo-demo    文件:SetContainsBenchmark.java   
@Benchmark boolean contains(int reps) {
  // Paranoia: acting on hearsay that accessing fields might be slow
  // Should write a benchmark to test that!
  Set<Element> set = setToTest;
  Element[] queries = this.queries;

  int mask = queries.length - 1;

  boolean dummy = false;
  for (int i = 0; i < reps; i++) {
    dummy ^= set.contains(queries[i & mask]);
  }
  return dummy;
}
项目:guava-libraries    文件:SetIterationBenchmark.java   
@Benchmark int iteration(int reps) {
  int x = 0;

  for (int i = 0; i < reps; i++) {
    for (Element y : setToTest) {
      x ^= System.identityHashCode(y);
    }
  }
  return x;
}
项目:guava-libraries    文件:MapBenchmark.java   
@Override Map<Element, Element> create(Collection<Element> keys) {
  Map<Element, Element> map = Maps.newHashMap();
  for (Element element: keys) {
    map.put(element, element);
  }
  return map;
}