Skip to content

Commit

Permalink
fix: remove the only compiler warning (neo-project#3623)
Browse files Browse the repository at this point in the history
Co-authored-by: NGD Admin <[email protected]>
  • Loading branch information
nan01ab and NGDAdmin authored Dec 16, 2024
1 parent 3669912 commit 692cfbb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<ProjectReference Include="..\..\src\Neo.Extensions\Neo.Extensions.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<ProjectReference Include="..\..\src\Neo.Extensions\Neo.Extensions.csproj" />
<ProjectReference Include="..\..\src\Neo.Json\Neo.Json.csproj" />
<ProjectReference Include="..\..\src\Neo.VM\Neo.VM.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<ProjectReference Include="..\..\tests\Neo.VM.Tests\Neo.VM.Tests.csproj" />
</ItemGroup>

</Project>
24 changes: 22 additions & 2 deletions benchmarks/Neo.VM.Benchmarks/OpCode/BenchmarkEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using Neo.Test.Types;
using Neo.VM.Types;
using System.Diagnostics;
using System.Runtime.CompilerServices;

Expand All @@ -18,12 +18,14 @@ namespace Neo.VM.Benchmark.OpCode
/// <summary>
/// A simple benchmark engine for <see cref="ExecutionEngine"/>.
/// </summary>
public class BenchmarkEngine : TestEngine
public class BenchmarkEngine : ExecutionEngine
{
private readonly Dictionary<VM.OpCode, (int Count, TimeSpan TotalTime)> _opcodeStats = new();
private readonly Dictionary<Script, HashSet<uint>> _breakPoints = new();
private long _gasConsumed = 0;

public BenchmarkEngine() : base(ComposeJumpTable()) { }

/// <summary>
/// Add a breakpoint at the specified position of the specified script. The VM will break the execution when it reaches the breakpoint.
/// </summary>
Expand Down Expand Up @@ -187,5 +189,23 @@ private void PrintOpcodeStats()
$"Avg Time: {kvp.Value.TotalTime.TotalMilliseconds * 1000 / kvp.Value.Count,10:F2} μs");
}
}

private static JumpTable ComposeJumpTable()
{
JumpTable jumpTable = new JumpTable();
jumpTable[VM.OpCode.SYSCALL] = OnSysCall;
return jumpTable;
}

private static void OnSysCall(ExecutionEngine engine, VM.Instruction instruction)
{
uint method = instruction.TokenU32;
if (method == 0x77777777)
engine.CurrentContext!.EvaluationStack.Push(StackItem.FromInterface(new object()));
else if (method == 0xaddeadde)
engine.JumpTable.ExecuteThrow(engine, "error");
else
throw new Exception();
}
}
}
1 change: 0 additions & 1 deletion benchmarks/Neo.VM.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
}

var methods = benchmarkType.GetMethods(BindingFlags.Public | BindingFlags.Instance);

foreach (var method in methods)
{
if (method.DeclaringType == benchmarkType && !method.GetCustomAttributes<GlobalSetupAttribute>().Any())
Expand Down

0 comments on commit 692cfbb

Please sign in to comment.