3030 * <li>{@code array} / {@code sortedArray} — linear scan / binary search; slow on miss.
3131 * <li>{@link HashSet} — idiomatic, fast; node-based, allocates per element.
3232 * <li>{@link TreeSet} — comparator-ordered; worth it only for a custom comparator, not speed.
33- * <li>{@link java.util.Set#copyOf} (via {@link CollectionUtils#tryMakeImmutableSet}) — the JDK's
34- * compact, array-backed immutable set ({@code ImmutableCollections.SetN}), which is what the
35- * agent actually uses for fixed config sets. Java 10+; falls back to {@code HashSet} pre-10.
36- * The realistic baseline for any flat/immutable set comparison.
33+ * <li>{@code tracerImmutableSet} — {@link java.util.Set#copyOf} (via {@link
34+ * CollectionUtils#tryMakeImmutableSet}), the JDK's compact, array-backed immutable set
35+ * ({@code ImmutableCollections.SetN}), which is what the agent actually uses for fixed config
36+ * sets. Java 10+; falls back to {@code HashSet} pre-10. The realistic baseline for any
37+ * flat/immutable set comparison.
3738 * </ul>
3839 *
3940 * <p>Lookups are interned (the {@code ==} fast path where a structure has one); misses are short
4445 * <pre>{@code
4546 * Structure hit miss
4647 * hashSet 2159 1751 (fastest)
47- * copyOf (SetN) 1946 1633
48+ * tracerImmutableSet 1946 1633 (Set.copyOf / SetN)
4849 * array 926 584
4950 * sortedArray 664 588
5051 * treeSet 642 593
@@ -88,7 +89,7 @@ static String[] newMisses() {
8889 String [] sortedArray ;
8990 HashSet <String > hashSet ;
9091 TreeSet <String > treeSet ;
91- Set <String > copyOfSet ;
92+ Set <String > tracerImmutableSet ;
9293
9394 @ Setup (Level .Trial )
9495 public void setUp () {
@@ -97,7 +98,7 @@ public void setUp() {
9798 Arrays .sort (sortedArray );
9899 hashSet = new HashSet <>(Arrays .asList (STRINGS ));
99100 treeSet = new TreeSet <>(Arrays .asList (STRINGS ));
100- copyOfSet = CollectionUtils .tryMakeImmutableSet (Arrays .asList (STRINGS ));
101+ tracerImmutableSet = CollectionUtils .tryMakeImmutableSet (Arrays .asList (STRINGS ));
101102 }
102103
103104 /** Per-thread lookup cursor so each reader thread cycles keys independently. */
@@ -175,12 +176,12 @@ public boolean treeSet_miss(Cursor cursor) {
175176 }
176177
177178 @ Benchmark
178- public boolean copyOf_hit (Cursor cursor ) {
179- return copyOfSet .contains (cursor .nextHit ());
179+ public boolean tracerImmutableSet_hit (Cursor cursor ) {
180+ return tracerImmutableSet .contains (cursor .nextHit ());
180181 }
181182
182183 @ Benchmark
183- public boolean copyOf_miss (Cursor cursor ) {
184- return copyOfSet .contains (cursor .nextMiss ());
184+ public boolean tracerImmutableSet_miss (Cursor cursor ) {
185+ return tracerImmutableSet .contains (cursor .nextMiss ());
185186 }
186187}
0 commit comments