41 public class Clone { |
41 public class Clone { |
42 |
42 |
43 private BitSet testObj1; |
43 private BitSet testObj1; |
44 private Date testObj2; |
44 private Date testObj2; |
45 private char[] testObj3; |
45 private char[] testObj3; |
|
46 private char[] testObj4; |
|
47 private String[] testObj5; |
46 |
48 |
47 @Setup |
49 @Setup |
48 public void setup() { |
50 public void setup() { |
49 testObj1 = new BitSet(10); |
51 testObj1 = new BitSet(10); |
50 testObj2 = new Date(); |
52 testObj2 = new Date(); |
51 testObj3 = new char[5]; |
53 testObj3 = new char[5]; |
|
54 testObj4 = new char[311]; |
|
55 String str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut"; |
|
56 testObj5 = str.split(" ", -1); |
52 } |
57 } |
53 |
58 |
54 /** Calls clone on three different types. The types are java.util.BitSet, java.util.Date and char[]. */ |
59 /** Calls clone on three different types. The types are java.util.BitSet, java.util.Date and char[]. */ |
55 @Benchmark |
60 @Benchmark |
56 public void cloneThreeDifferent(Blackhole bh) { |
61 public void cloneThreeDifferent(Blackhole bh) { |
57 bh.consume(testObj1.clone()); |
62 bh.consume(testObj1.clone()); |
58 bh.consume(testObj2.clone()); |
63 bh.consume(testObj2.clone()); |
59 bh.consume(testObj3.clone()); |
64 bh.consume(testObj3.clone()); |
60 } |
65 } |
61 |
66 |
|
67 @Benchmark |
|
68 public void cloneLarge(Blackhole bh) { |
|
69 bh.consume(testObj4.clone()); |
|
70 bh.consume(testObj5.clone()); |
|
71 } |
|
72 |
62 } |
73 } |
63 |
74 |