diff --git a/Jint.Benchmark/StringSliceBenchmarks.cs b/Jint.Benchmark/StringSliceBenchmarks.cs new file mode 100644 index 0000000000..8687b3f8d4 --- /dev/null +++ b/Jint.Benchmark/StringSliceBenchmarks.cs @@ -0,0 +1,97 @@ +using BenchmarkDotNet.Attributes; +using Jint.Native; + +namespace Jint.Benchmark; + +/// +/// Isolates String.prototype.slice/substring/substr cost over a large (128K char) string — +/// the dromaeo-object-string shape where large slice results are assigned and discarded +/// (measured: slice = 89.9%, substring = 9.2% of its 1.26 GB/op allocations). +/// SliceSmall guards the small-result path; SliceThenRead guards lazy-materialization cost +/// when the result is actually consumed. +/// +[MemoryDiagnoser] +[HideColumns("Error", "Gen0", "Gen1", "Gen2")] +public class StringSliceBenchmarks +{ + private Engine _engine = null!; + private Prepared