Skip to content

Commit d9e652b

Browse files
committed
Refactoring Maps.java benchmark
1 parent 71a6aa7 commit d9e652b

2 files changed

Lines changed: 12 additions & 94 deletions

File tree

understandingcollections/MapPerformance.java

Lines changed: 0 additions & 82 deletions
This file was deleted.

understandingcollections/jmhtests/MapPerformance.java renamed to understandingcollections/jmhtests/Maps.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// understandingcollections/jmhtests/MapPerformance.java
1+
// understandingcollections/jmhtests/Maps.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
@@ -15,11 +15,11 @@
1515
@Fork(1)
1616
@BenchmarkMode(Mode.AverageTime)
1717
@OutputTimeUnit(NANOSECONDS)
18-
public class MapPerformance {
18+
public class Maps {
1919
private Map<Integer, Integer> map;
2020

21-
@Param({"hashmap", "treemap", "linkedhashmap",
22-
"identityhashmap", "weakhashmap", "hashtable"})
21+
@Param({"HashMap", "TreeMap", "LinkedHashMap",
22+
"IdentityHashMap", "WeakHashMap", "Hashtable",})
2323
private String type;
2424

2525
private int begin;
@@ -28,22 +28,22 @@ public class MapPerformance {
2828
@Setup
2929
public void setup() {
3030
switch(type) {
31-
case "hashmap":
31+
case "HashMap":
3232
map = new HashMap<>();
3333
break;
34-
case "treemap":
34+
case "TreeMap":
3535
map = new TreeMap<>();
3636
break;
37-
case "linkedhashmap":
37+
case "LinkedHashMap":
3838
map = new LinkedHashMap<>();
3939
break;
40-
case "identityhashmap":
40+
case "IdentityHashMap":
4141
map = new IdentityHashMap<>();
4242
break;
43-
case "weakhashmap":
43+
case "WeakHashMap":
4444
map = new WeakHashMap<>();
4545
break;
46-
case "hashtable":
46+
case "Hashtable":
4747
map = new Hashtable<>();
4848
break;
4949
default:
@@ -65,9 +65,9 @@ public void get(Blackhole bh) {
6565
}
6666

6767
@Benchmark
68-
public void put(Blackhole bh) {
68+
public void put() {
6969
for (int i = begin; i < end; i++) {
70-
bh.consume(map.put(i, i));
70+
map.put(i, i);
7171
}
7272
}
7373

0 commit comments

Comments
 (0)