diff --git a/Jint.Benchmark/ArrayHoleTraversalBenchmark.cs b/Jint.Benchmark/ArrayHoleTraversalBenchmark.cs new file mode 100644 index 000000000..b7d390379 --- /dev/null +++ b/Jint.Benchmark/ArrayHoleTraversalBenchmark.cs @@ -0,0 +1,141 @@ +using BenchmarkDotNet.Attributes; +using Jint.Native; + +namespace Jint.Benchmark; + +/// +/// Traversal cost of holey (but still dense-backed) arrays versus packed ones. Reading a hole +/// falls off the dense fast path and probes the prototype chain per element (the spec requires a +/// HasProperty/Get walk), so index loops, join and indexOf pay a per-hole penalty that a packed +/// array never sees. The dense/holey lane pairs measure that gap; `in` exercises the raw +/// HasProperty probe. +/// +[MemoryDiagnoser] +[HideColumns("Error", "Gen0", "Gen1", "Gen2")] +public class ArrayHoleTraversalBenchmark +{ + private Engine _engine = null!; + private Prepared