diff --git a/Jint.Benchmark/GuardComparisonBenchmark.cs b/Jint.Benchmark/GuardComparisonBenchmark.cs new file mode 100644 index 000000000..bc37dd9d3 --- /dev/null +++ b/Jint.Benchmark/GuardComparisonBenchmark.cs @@ -0,0 +1,132 @@ +using BenchmarkDotNet.Attributes; +using Jint.Native; + +namespace Jint.Benchmark; + +/// +/// Guard-style strict comparisons over LCG-mixed inputs the branch predictor cannot memorize: +/// `v === undefined`, `v === null`, `v == null` and `typeof v === '...'` — the idioms defensive +/// library code (linq.js, lodash, handlebars) runs on nearly every call. +/// +[MemoryDiagnoser] +[HideColumns("Error", "Gen0", "Gen1", "Gen2")] +public class GuardComparisonBenchmark +{ + private Engine _engine = null!; + private Prepared