Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove unnecessary file * composition over inheritance * inline WasmAppBuilder into WasmBuilder * add WASM to R# dictionary * simplify WASM console line arguments * add validation that prints errors * merge WasmSettings into WasmRuntime * extend Executor to support WasmRuntime, remove WasmExecutor * when toolchain was not specified, create it our of provided WasmRuntime * expose WasmRuntime.Default that returns something consumable by RuntimeInformation.GetCurrentRuntime() * final polishing
- Loading branch information
1 parent
908b09b
commit 1ff50ae
Showing
15 changed files
with
187 additions
and
371 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,22 +1,60 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using BenchmarkDotNet.Extensions; | ||
using BenchmarkDotNet.Jobs; | ||
|
||
namespace BenchmarkDotNet.Environments | ||
{ | ||
public class WasmRuntime : Runtime, IEquatable<WasmRuntime> | ||
{ | ||
public static readonly WasmRuntime Default = new WasmRuntime("Wasm"); | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
internal static readonly WasmRuntime Default = new WasmRuntime(); | ||
|
||
public WasmRuntime(string name) : base(RuntimeMoniker.Wasm, "net5.0", name) | ||
public FileInfo MainJs { get; } | ||
|
||
public string JavaScriptEngine { get; } | ||
|
||
public string JavaScriptEngineArguments { get; } | ||
|
||
/// <summary> | ||
/// creates new instance of WasmRuntime | ||
/// </summary> | ||
/// <param name="mainJs">MANDATORY path to the main.js file.</param> | ||
/// <param name="javaScriptEngine">Full path to a java script engine used to run the benchmarks. "v8" by default</param> | ||
/// <param name="javaScriptEngineArguments">Arguments for the javascript engine. "--expose_wasm" by default</param> | ||
/// <param name="msBuildMoniker">moniker, default: "net5.0"</param> | ||
/// <param name="displayName">default: "WASM"</param> | ||
/// <remarks>path to mainJs MUST be provided</remarks> | ||
public WasmRuntime(FileInfo mainJs, string msBuildMoniker = "net5.0", string displayName = "WASM", string javaScriptEngine = "v8", string javaScriptEngineArguments = "--expose_wasm") : base(RuntimeMoniker.Wasm, msBuildMoniker, displayName) | ||
{ | ||
if (mainJs == null) | ||
throw new ArgumentNullException(paramName: nameof(mainJs)); | ||
if (mainJs.IsNotNullButDoesNotExist()) | ||
throw new FileNotFoundException($"Provided {nameof(mainJs)} file: \"{mainJs.FullName}\" doest NOT exist"); | ||
if (!string.IsNullOrEmpty(javaScriptEngine) && javaScriptEngine != "v8" && !File.Exists(javaScriptEngine)) | ||
throw new FileNotFoundException($"Provided {nameof(javaScriptEngine)} file: \"{javaScriptEngine}\" doest NOT exist"); | ||
|
||
MainJs = mainJs; | ||
JavaScriptEngine = javaScriptEngine; | ||
JavaScriptEngineArguments = javaScriptEngineArguments; | ||
} | ||
|
||
public WasmRuntime(string name, string msBuildMoniker) : base(RuntimeMoniker.Wasm, msBuildMoniker, name) | ||
|
||
// this ctor exists only for the purpose of having .Default property that returns something consumable by RuntimeInformation.GetCurrentRuntime() | ||
private WasmRuntime(string msBuildMoniker = "net5.0", string displayName = "WASM", string javaScriptEngine = "v8", string javaScriptEngineArguments = "--expose_wasm") : base(RuntimeMoniker.Wasm, msBuildMoniker, displayName) | ||
{ | ||
MainJs = new FileInfo("fake"); | ||
JavaScriptEngine = javaScriptEngine; | ||
JavaScriptEngineArguments = javaScriptEngineArguments; | ||
} | ||
|
||
public override bool Equals(object obj) => obj is WasmRuntime other && Equals(other); | ||
public override bool Equals(object obj) | ||
=> obj is WasmRuntime other && Equals(other); | ||
|
||
public bool Equals(WasmRuntime other) | ||
=> other != null && base.Equals(other) && other.MainJs == MainJs && other.JavaScriptEngine == JavaScriptEngine && other.JavaScriptEngineArguments == JavaScriptEngineArguments; | ||
|
||
public bool Equals(WasmRuntime other) => base.Equals(other); | ||
public override int GetHashCode() | ||
=> base.GetHashCode() ^ MainJs.GetHashCode() ^ (JavaScriptEngine?.GetHashCode() ?? 0) ^ (JavaScriptEngineArguments?.GetHashCode() ?? 0); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.