BenchmarkCore.cs 957 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Lua;
  2. using MoonSharp.Interpreter;
  3. public class BenchmarkCore : IDisposable
  4. {
  5. public NLua.Lua NLuaState => nLuaState;
  6. public Script MoonSharpState => moonSharpState;
  7. public LuaGlobalState LuaGlobalCSharpState => luaGlobalCSharpState;
  8. public string FilePath => filePath;
  9. public string SourceText => sourceText;
  10. NLua.Lua nLuaState = default!;
  11. Script moonSharpState = default!;
  12. LuaGlobalState luaGlobalCSharpState = default!;
  13. string filePath = default!;
  14. string sourceText = default!;
  15. public void Setup(string fileName)
  16. {
  17. // moonsharp
  18. moonSharpState = new();
  19. Script.WarmUp();
  20. // NLua
  21. nLuaState = new();
  22. // Lua-CSharp
  23. luaGlobalCSharpState = LuaGlobalState.Create();
  24. filePath = FileHelper.GetAbsolutePath(fileName);
  25. sourceText = File.ReadAllText(filePath);
  26. }
  27. public void Dispose()
  28. {
  29. nLuaState.Dispose();
  30. }
  31. }