-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from stevehalliwell/tracing
Merge tracing into main
- Loading branch information
Showing
15 changed files
with
308 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using NUnit.Framework; | ||
|
||
namespace ULox.Core.Tests | ||
{ | ||
public class TracingTests : EngineTestBase | ||
{ | ||
[Test] | ||
public void VmStatisticsReport_WhenSimpleMathOps_ShouldMatchExpected() | ||
{ | ||
testEngine.Run(@" | ||
var a = 1; | ||
var b = 2; | ||
var c = a + b; | ||
print(c); | ||
var d = Math.Sqrt(c); | ||
"); | ||
var statsReport = VmStatisticsReport.Create(testEngine.MyEngine.Context.Vm.Tracing.PerChunkStats).GenerateStringReport(); | ||
|
||
Assert.AreEqual("3", testEngine.InterpreterResult); | ||
StringAssert.Contains("ADD 1", statsReport); | ||
StringAssert.Contains("FETCH_GLOBAL 6", statsReport); | ||
} | ||
|
||
[Test] | ||
public void Tracing_WhenEnabledAndSimpleMathOps_ShouldMatchExpected() | ||
{ | ||
testEngine.MyEngine.Context.Vm.Tracing.EnableTracing = true; | ||
testEngine.Run(@" | ||
var a = 1; | ||
var b = 2; | ||
var c = a + b; | ||
print(c); | ||
var d = Math.Sqrt(c); | ||
"); | ||
var statsReport = VmTracingReport.Create(testEngine.MyEngine.Context.Vm.Tracing.TimeLineEvents).GenerateJsonTracingEventArray(); | ||
|
||
Assert.AreEqual("3", testEngine.InterpreterResult); | ||
StringAssert.Contains("\"name\":\"print\",\"ph\":\"B\"", statsReport); | ||
StringAssert.Contains("\"name\":\"Sqrt\",\"ph\":\"E\"", statsReport); | ||
} | ||
|
||
[Test] | ||
public void Tracing_WhenDisabledAndSimpleMathOps_ShouldMatchExpected() | ||
{ | ||
testEngine.Run(@" | ||
var a = 1; | ||
var b = 2; | ||
var c = a + b; | ||
print(c); | ||
var d = Math.Sqrt(c); | ||
"); | ||
var statsReport = VmTracingReport.Create(testEngine.MyEngine.Context.Vm.Tracing.TimeLineEvents).GenerateJsonTracingEventArray(); | ||
|
||
Assert.AreEqual("3", testEngine.InterpreterResult); | ||
StringAssert.DoesNotContain("\"name\":\"print\",\"ph\":\"B\"", statsReport); | ||
StringAssert.DoesNotContain("\"name\":\"Sqrt\",\"ph\":\"E\"", statsReport); | ||
} | ||
|
||
[Test] | ||
public void Tracing_WhenEnabledAndInstancesAndSimpleMathOps_ShouldMatchExpected() | ||
{ | ||
testEngine.MyEngine.Context.Vm.Tracing.EnableTracing = true; | ||
testEngine.MyEngine.Context.Vm.Tracing.EnableOpCodeInstantTraces = true; | ||
testEngine.Run(@" | ||
var a = 1; | ||
var b = 2; | ||
var c = a + b; | ||
print(c); | ||
var d = Math.Sqrt(c); | ||
"); | ||
var statsReport = VmTracingReport.Create(testEngine.MyEngine.Context.Vm.Tracing.TimeLineEvents).GenerateJsonTracingEventArray(); | ||
|
||
Assert.AreEqual("3", testEngine.InterpreterResult); | ||
StringAssert.Contains("\"name\":\"print\",\"ph\":\"B\"", statsReport); | ||
StringAssert.Contains("\"name\":\"Sqrt\",\"ph\":\"E\"", statsReport); | ||
StringAssert.Contains("\"name\":\"FETCH_GLOBAL\",\"ph\":\"I\",\"", statsReport); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.