@Benchmark public void defaultPut(final Blackhole blackhole) { final Map<Integer, String> ourMap = this.ourMap; final List<Integer> indexes = this.indexes; final List<String> values = this.values; for (int i = 0, n = indexes.size(); i < n; i++) { blackhole.consume(defaultMap.put(indexes.get(i), values.get(i))); } }
@Setup public void setup() { for (int i = 0; i < size; i++) { ourMap.put(i, String.valueOf(i)); defaultMap.put(i, String.valueOf(i)); } indexes = new ArrayList<>(); values = new ArrayList<>(); Random random = new Random(100); for (int i = 1; i <= 100; i++) { int index = random.nextInt(size); indexes.add(index); values.add(String.valueOf(index)); } }
@Setup public void setup(Blackhole bh) { arrayList = new ArrayList<>(); arrayList.add(1); lambda = SingletonSet.of(1); lambdaBugged = SingletonSetBugged.of(1); ix = Ix.just(1); singleton = Collections.singleton(1); singletonList = Collections.singletonList(1); c = bh::consume; }
@GenerateMicroBenchmark public int serialArrayList() { return arrayList.stream().mapToInt(i -> i).sum(); }
// BEGIN addIntegers private int addIntegers(List<Integer> values) { return values.parallelStream().mapToInt(i -> i).sum(); }
@GenerateMicroBenchmark public int arrayList() { return arrayList.parallelStream().mapToInt(i -> i).sum(); }
// @Benchmark public void arrayList() { arrayList.forEach(c); }