Skip to content

Commit

Permalink
fixup: use Collections.unmodifiableMap
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert committed Oct 22, 2024
1 parent 5c86f3a commit f518c31
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
94 changes: 47 additions & 47 deletions benchmark.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,49 +125,49 @@ Audit done.

# Run progress: 0.00% complete, ETA 00:00:00
# Fork: 1 of 1
[0.001s][warning][gc,init] Consider setting -Xms equal to -Xmx to avoid resizing hiccups
[0.001s][warning][gc,init] Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups
[0.003s][warning][gc,init] Consider setting -Xms equal to -Xmx to avoid resizing hiccups
[0.003s][warning][gc,init] Consider enabling -XX:+AlwaysPreTouch to avoid memory commit hiccups
Iteration 1: num #instances #bytes class name (module)
-------------------------------------------------------
1: 570958 27405984 java.util.HashMap ([email protected])
2: 355982 10905560 [Ljava.lang.Object; ([email protected])
3: 47720 9713208 [B ([email protected])
4: 260500 4168000 dev.openfeature.sdk.ImmutableStructure
5: 250500 4008000 dev.openfeature.sdk.ImmutableContext
6: 166703 4000872 java.util.ArrayList ([email protected])
7: 100000 4000000 dev.openfeature.sdk.HookContext
8: 100000 4000000 dev.openfeature.sdk.HookContext$HookContextBuilder
9: 108963 3486816 java.util.HashMap$EntryIterator ([email protected])
10: 92789 2969248 java.util.ArrayList$Itr ([email protected])
11: 160056 2560896 java.util.HashMap$EntrySet ([email protected])
12: 50000 2400000 dev.openfeature.sdk.FlagEvaluationDetails$FlagEvaluationDetailsBuilder
13: 140 2038632 [Ljdk.internal.vm.FillerElement; ([email protected])
14: 50000 2000000 dev.openfeature.sdk.FlagEvaluationDetails
15: 50000 2000000 dev.openfeature.sdk.ProviderEvaluation
16: 50002 1600064 java.util.Collections$UnmodifiableMap ([email protected])
17: 100001 1600016 dev.openfeature.sdk.NoOpProvider$$Lambda/0x00007b8b5002fa78
18: 50000 1600000 [Ljava.util.List; ([email protected])
19: 100000 1600000 dev.openfeature.sdk.ImmutableMetadata
20: 100000 1600000 dev.openfeature.sdk.OpenFeatureClient$$Lambda/0x00007b8b50087590
1: 560594 26908512 java.util.HashMap ([email protected])
2: 355983 10905600 [Ljava.lang.Object; ([email protected])
3: 47720 9713248 [B ([email protected])
4: 270056 4320896 java.util.HashMap$EntrySet ([email protected])
5: 250136 4002176 dev.openfeature.sdk.ImmutableStructure
6: 100000 4000000 dev.openfeature.sdk.HookContext
7: 100000 4000000 dev.openfeature.sdk.HookContext$HookContextBuilder
8: 240136 3842176 dev.openfeature.sdk.ImmutableContext
9: 147218 3533232 java.util.ArrayList ([email protected])
10: 142 3416648 [Ljdk.internal.vm.FillerElement; ([email protected])
11: 88243 2823776 java.util.HashMap$EntryIterator ([email protected])
12: 67693 2166176 java.util.ArrayList$Itr ([email protected])
13: 50000 2000000 dev.openfeature.sdk.FlagEvaluationDetails
14: 50000 2000000 dev.openfeature.sdk.ProviderEvaluation
15: 60346 1931072 java.util.Collections$UnmodifiableMap ([email protected])
16: 100001 1600016 dev.openfeature.sdk.NoOpProvider$$Lambda/0x000074791c02fa78
17: 50000 1600000 [Ljava.util.List; ([email protected])
18: 100000 1600000 dev.openfeature.sdk.ImmutableMetadata
19: 100000 1600000 dev.openfeature.sdk.ImmutableMetadata$ImmutableMetadataBuilder
20: 100000 1600000 dev.openfeature.sdk.OpenFeatureClient$$Lambda/0x000074791c087590
21: 50000 1200000 dev.openfeature.sdk.FlagEvaluationOptions
22: 68852 1101632 java.util.Optional ([email protected])
23: 66820 1069120 dev.openfeature.sdk.ImmutableMetadata$ImmutableMetadataBuilder
24: 23186 927440 dev.openfeature.sdk.ProviderEvaluation$ProviderEvaluationBuilder
25: 34250 822000 dev.openfeature.sdk.FlagEvaluationOptions$FlagEvaluationOptionsBuilder
22: 20617 989616 dev.openfeature.sdk.FlagEvaluationDetails$FlagEvaluationDetailsBuilder
23: 60896 974336 java.util.Optional ([email protected])
24: 34775 834600 dev.openfeature.sdk.FlagEvaluationOptions$FlagEvaluationOptionsBuilder
25: 18750 750000 dev.openfeature.sdk.ProviderEvaluation$ProviderEvaluationBuilder
26: 4488 720648 [I ([email protected])
27: 26532 636768 java.lang.String ([email protected])
28: 26292 420672 dev.openfeature.sdk.internal.AutoCloseableReentrantReadWriteLock$$Lambda/0x00007b8b5002eae8
29: 17163 411912 dev.openfeature.sdk.HookSupport$$Lambda/0x00007b8b50081800
27: 27435 658440 dev.openfeature.sdk.HookSupport$$Lambda/0x000074791c081800
28: 26532 636768 java.lang.String ([email protected])
29: 23197 556728 dev.openfeature.sdk.HookSupport$$Lambda/0x000074791c083d78
30: 1461 390008 [J ([email protected])
31: 13411 321864 dev.openfeature.sdk.HookSupport$$Lambda/0x00007b8b50083d78
32: 2354 287992 java.lang.Class ([email protected])
31: 21557 344912 dev.openfeature.sdk.internal.AutoCloseableReentrantReadWriteLock$$Lambda/0x000074791c02eae8
32: 2356 288224 java.lang.Class ([email protected])
33: 4591 257096 jdk.internal.org.objectweb.asm.SymbolTable$Entry ([email protected])
34: 10001 240024 java.lang.Double ([email protected])
35: 8754 210096 java.util.ImmutableCollections$MapN$MapNIterator ([email protected])
34: 10344 248256 java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$1 ([email protected])
35: 10001 240024 java.lang.Double ([email protected])
36: 2502 180144 java.lang.reflect.Field ([email protected])
37: 10000 160000 dev.openfeature.sdk.Value
38: 5996 143904 java.lang.StringBuilder ([email protected])
39: 8754 140064 java.util.ImmutableCollections$MapN$1 ([email protected])
37: 10344 165504 java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet ([email protected])
38: 10000 160000 dev.openfeature.sdk.Value
39: 5996 143904 java.lang.StringBuilder ([email protected])
40: 178 138888 [Ljdk.internal.org.objectweb.asm.SymbolTable$Entry; ([email protected])
41: 3820 122240 java.util.concurrent.ConcurrentHashMap$Node ([email protected])
42: 48 122168 [C ([email protected])
Expand Down Expand Up @@ -248,20 +248,20 @@ Iteration 1: num #instances #bytes class name (module)
117: 158 5056 java.lang.invoke.MethodTypeForm ([email protected])
118: 152 4864 java.nio.file.attribute.FileTime ([email protected])
truncated...
Total 3202963 105723696
Total 3237354 105727792

0.141 s/op
+totalAllocatedBytes: 105723696.000 bytes
+totalAllocatedInstances: 3202963.000 instances
0.132 s/op
+totalAllocatedBytes: 105727792.000 bytes
+totalAllocatedInstances: 3237354.000 instances
+totalHeap: 521412608.000 bytes



Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalAllocatedBytes":
105723696.000 bytes
105727792.000 bytes

Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalAllocatedInstances":
3202963.000 instances
3237354.000 instances

Secondary result "dev.openfeature.sdk.benchmark.AllocationBenchmark.run:+totalHeap":
521412608.000 bytes
Expand All @@ -282,13 +282,13 @@ different JVMs are already problematic, the performance difference caused by dif
modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons.

Benchmark Mode Cnt Score Error Units
AllocationBenchmark.run ss 0.141 s/op
AllocationBenchmark.run:+totalAllocatedBytes ss 105723696.000 bytes
AllocationBenchmark.run:+totalAllocatedInstances ss 3202963.000 instances
AllocationBenchmark.run ss 0.132 s/op
AllocationBenchmark.run:+totalAllocatedBytes ss 105727792.000 bytes
AllocationBenchmark.run:+totalAllocatedInstances ss 3237354.000 instances
AllocationBenchmark.run:+totalHeap ss 521412608.000 bytes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.108 s
[INFO] Finished at: 2024-10-22T14:58:27-04:00
[INFO] Total time: 12.076 s
[INFO] Finished at: 2024-10-22T15:08:16-04:00
[INFO] ------------------------------------------------------------------------
3 changes: 2 additions & 1 deletion src/main/java/dev/openfeature/sdk/AbstractStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Collections;

@SuppressWarnings({ "PMD.BeanMembersShouldSerialize", "checkstyle:MissingJavadocType" })
abstract class AbstractStructure implements Structure {
Expand All @@ -26,7 +27,7 @@ public boolean isEmpty() {
* @return immutable map
*/
public Map<String, Value> asUnmodifiableMap() {
return Map.copyOf(attributes);
return Collections.unmodifiableMap(attributes);
}

/**
Expand Down

0 comments on commit f518c31

Please sign in to comment.