-
-
Notifications
You must be signed in to change notification settings - Fork 594
Expand file tree
/
Copy pathSingleScriptBenchmark.cs
More file actions
33 lines (27 loc) · 768 Bytes
/
SingleScriptBenchmark.cs
File metadata and controls
33 lines (27 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using BenchmarkDotNet.Attributes;
namespace Jint.Benchmark;
[MemoryDiagnoser]
public abstract class SingleScriptBenchmark
{
private string _script;
private Prepared<Script> _parsedScript;
protected abstract string FileName { get; }
[GlobalSetup]
public void Setup()
{
_script = File.ReadAllText($"Scripts/{FileName}");
_parsedScript = Engine.PrepareScript(_script, strict: true);
}
[Benchmark]
public void Execute()
{
var engine = new Engine(static options => options.Strict());
engine.Execute(_script);
}
[Benchmark]
public void Execute_ParsedScript()
{
var engine = new Engine(static options => options.Strict());
engine.Execute(_parsedScript);
}
}