Skip to content

Commit 5411414

Browse files
committed
Expand tracking of code optimizations - using ParserFast.allPattern
Add a test scenario looking closer at how `allPattern` declaration in the Elm syntax `ParserFast` library is emitted and executed at runtime. Observed metrics in this version: Invocation count: 5. Instruction count: 175. Looks like there are opportunities to optimize here.
1 parent 8edd6f3 commit 5411414

2 files changed

Lines changed: 466 additions & 0 deletions

File tree

implement/Pine.IntegrationTests/CodeAnalysis/CodeAnalysisTestHelper.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
using Pine.Core.CodeAnalysis;
66
using Pine.Core.DotNet;
77
using Pine.Core.Internal;
8+
using Pine.Core.PineVM;
89
using Pine.Core.PopularEncodings;
910
using Pine.Elm;
1011
using System.Collections.Frozen;
1112
using System.Collections.Generic;
13+
using System.Collections.Immutable;
1214
using System.Linq;
1315
using System.Text;
1416

@@ -154,4 +156,21 @@ public static (ElmInteractiveEnvironment.ParsedInteractiveEnvironment parsedEnv,
154156

155157
return (parsedEnv, staticProgram);
156158
}
159+
160+
161+
/// <summary>
162+
/// Create a VM with all optimizations disabled, to support repeatable profiling.
163+
/// </summary>
164+
public static IPineVM PineVMForProfiling(
165+
System.Action<PineVM.EvaluationReport> reportFunctionApplication)
166+
{
167+
var vm =
168+
new PineVM.PineVM(
169+
evalCache: null,
170+
disablePrecompiled: true,
171+
reportFunctionApplication: reportFunctionApplication,
172+
precompiledLeaves: ImmutableDictionary<PineValue, System.Func<PineValue, PineValue?>>.Empty);
173+
174+
return vm;
175+
}
157176
}

0 commit comments

Comments
 (0)