Skip to content

Commit

Permalink
fixup: comments
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert committed Oct 10, 2024
1 parent e68f221 commit 54ec304
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@
import dev.openfeature.sdk.OpenFeatureAPI;
import dev.openfeature.sdk.Value;

/**
* Runs a large volume of flag evaluations on a VM with 1G memory and GC
* completely disabled so we can take a heap-dump.
*/
public class AllocationBenchmark {

// 10K iterations works well with Xmx1024m (we don't want to run out of memory)
private static final int ITERATIONS = 10000;

@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1)
Expand All @@ -44,7 +51,7 @@ public Optional<EvaluationContext> before(HookContext<Object> ctx, Map<String, O
}
});

for (int i = 0; i < 10000; i++) {
for (int i = 0; i < ITERATIONS; i++) {
client.getBooleanValue(BOOLEAN_FLAG_KEY, false);
client.getStringValue(STRING_FLAG_KEY, "default");
client.getIntegerValue(INT_FLAG_KEY, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
import org.openjdk.jmh.results.ScalarResult;
import org.openjdk.jmh.util.Utils;

/**
* Takes a heap dump (using JMAP from a separate process) after a benchmark;
* only useful if GC is disabled during the benchmark.
*/
public class AllocationProfiler implements InternalProfiler {

public static class AllocationTotals {
Expand Down

0 comments on commit 54ec304

Please sign in to comment.