diff --git a/Jint.Benchmark/AsyncFunctionExitBenchmark.cs b/Jint.Benchmark/AsyncFunctionExitBenchmark.cs new file mode 100644 index 000000000..ac5113e77 --- /dev/null +++ b/Jint.Benchmark/AsyncFunctionExitBenchmark.cs @@ -0,0 +1,61 @@ +using BenchmarkDotNet.Attributes; + +namespace Jint.Benchmark; + +/// +/// Measures async-function and async-generator EXIT cost in two shapes: +/// - "Plain": no `await using` declarations in scope; the dispose state machine +/// is skipped via the HasDisposeResources fast path. Goal: zero allocation +/// beyond the function/promise plumbing itself. +/// - "WithSyncUsing": one `using` declaration with a sync dispose method; the +/// state machine runs but never suspends. +/// Compares against the pre-PR-2478 "everything inline-disposes" code path by +/// running many iterations so per-call allocation differences dominate. +/// +[MemoryDiagnoser] +public class AsyncFunctionExitBenchmark +{ + private Prepared