From f3279874b7b1826c846605412a3d20805510968f Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Mon, 13 Jul 2026 15:38:42 +0300 Subject: [PATCH] Add Proxy trap dispatch benchmarks New ProxyBenchmark lane measuring per-operation Proxy trap machinery: get/set/has through an explicit handler vs an empty forwarding handler, ownKeys via Object.keys, apply/construct on a function proxy, revocable create+revoke churn, and typeof on a revoked function proxy (must not throw). Prepared scripts on a single engine, standard MemoryDiagnoser lane layout. No product code changes. ConstructTrap passes two constructor arguments on purpose: a single numeric argument currently trips Array(n) length semantics when JsProxy.Construct builds the trap argumentsList via the Array constructor instead of CreateArrayFromList. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01EsHuKuE4UihKZp5HYapDHE --- Jint.Benchmark/ProxyBenchmark.cs | 239 +++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 Jint.Benchmark/ProxyBenchmark.cs diff --git a/Jint.Benchmark/ProxyBenchmark.cs b/Jint.Benchmark/ProxyBenchmark.cs new file mode 100644 index 000000000..365dacdc5 --- /dev/null +++ b/Jint.Benchmark/ProxyBenchmark.cs @@ -0,0 +1,239 @@ +using BenchmarkDotNet.Attributes; +using Jint.Native; + +namespace Jint.Benchmark; + +/// +/// Proxy trap dispatch: get/set/has/ownKeys through an explicit handler versus an empty +/// (forwarding) handler, apply/construct on a function proxy, revocable creation + revoke +/// churn, and typeof on a revoked function proxy (which must not throw). Rows measure the +/// per-operation trap machinery — handler lookup, trap invocation and invariant checks. +/// +[MemoryDiagnoser] +[HideColumns("Error", "Gen0", "Gen1", "Gen2")] +public class ProxyBenchmark +{ + private Engine _engine = null!; + private Prepared