mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8238684: Override getOrDefault in immutable Map implementation
Reviewed-by: forax, psandoz, smarks
This commit is contained in:
parent
7552915d3f
commit
ac69c7894d
2 changed files with 24 additions and 0 deletions
|
@ -34,6 +34,9 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
@State(Scope.Benchmark)
|
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||
@Fork(value = 3)
|
||||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
|
||||
public class ImmutableColls {
|
||||
|
||||
public static String[] STRINGS = {"hi", "all", "of", "you"};
|
||||
|
@ -217,6 +220,13 @@ public class ImmutableColls {
|
|||
fm4.containsValue("hi");
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
|
||||
public void getOrDefault(Blackhole bh) {
|
||||
bh.consume(fm4.getOrDefault("hi", "test"));
|
||||
bh.consume(fm4.getOrDefault("not_in_this_map", "test"));
|
||||
}
|
||||
|
||||
public int sizeOf(List<String> list) {
|
||||
return list.size();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue