diff --git a/Jint.Benchmark/FunctionDeclarationAllocBenchmark.cs b/Jint.Benchmark/FunctionDeclarationAllocBenchmark.cs new file mode 100644 index 000000000..848c91530 --- /dev/null +++ b/Jint.Benchmark/FunctionDeclarationAllocBenchmark.cs @@ -0,0 +1,47 @@ +using BenchmarkDotNet.Attributes; +using Jint.Native; + +namespace Jint.Benchmark; + +/// +/// Isolates the allocation cost of creating functions that are never used as constructors and whose +/// .prototype is never read — the linq-js cold-start shape, where hundreds of helper functions +/// are declared but essentially none are new-ed. With a lazy .prototype each such function +/// skips its prototype object + two descriptor allocations. is the guard: +/// when the functions ARE used as constructors the prototype must still materialize (no allocation win, +/// no regression). +/// +[MemoryDiagnoser] +[HideColumns("Error", "Gen0", "Gen1", "Gen2")] +public class FunctionDeclarationAllocBenchmark +{ + private Engine _engine = null!; + private Prepared