Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions JetStreamDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,32 @@ class WasmLegacyBenchmark extends Benchmark {
}
};

function dotnetPreloads(type)
{
return {
dotnetUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/dotnet.js`,
dotnetNativeUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/dotnet.native.js`,
dotnetRuntimeUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/dotnet.runtime.js`,
wasmBinaryUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/dotnet.native.wasm`,
icuCustomUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/icudt_CJK.dat`,
dllCollectionsConcurrentUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Collections.Concurrent.wasm`,
dllCollectionsUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Collections.wasm`,
dllComponentModelPrimitivesUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.ComponentModel.Primitives.wasm`,
dllComponentModelTypeConverterUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.ComponentModel.TypeConverter.wasm`,
dllDrawingPrimitivesUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Drawing.Primitives.wasm`,
dllDrawingUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Drawing.wasm`,
dllIOPipelinesUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.IO.Pipelines.wasm`,
dllLinqUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Linq.wasm`,
dllMemoryUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Memory.wasm`,
dllObjectModelUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.ObjectModel.wasm`,
dllPrivateCorelibUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Private.CoreLib.wasm`,
dllRuntimeInteropServicesJavaScriptUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Runtime.InteropServices.JavaScript.wasm`,
dllTextEncodingsWebUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Text.Encodings.Web.wasm`,
dllTextJsonUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/System.Text.Json.wasm`,
dllAppUrl: `./wasm/dotnet/build-${type}/wwwroot/_framework/dotnet.wasm`,
}
}

let BENCHMARKS = [
// ARES
new DefaultBenchmark({
Expand Down Expand Up @@ -2248,6 +2274,29 @@ let BENCHMARKS = [
iterations: 40,
tags: ["Wasm"],
}),
// .NET
new AsyncBenchmark({
name: "dotnet-interp",
files: [
"./wasm/dotnet/interp.js",
"./wasm/dotnet/benchmark.js",
],
preload: dotnetPreloads("interp"),
iterations: 10,
worstCaseCount: 2,
tags: ["Wasm", "dotnet"]
}),
new AsyncBenchmark({
name: "dotnet-aot",
files: [
"./wasm/dotnet/aot.js",
"./wasm/dotnet/benchmark.js",
],
preload: dotnetPreloads("aot"),
iterations: 15,
worstCaseCount: 2,
tags: ["Wasm", "dotnet"]
})
];

// LuaJSFight tests
Expand Down
14 changes: 14 additions & 0 deletions in-depth.html
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,20 @@ <h3>
Source code: <a href="proxy/vue-benchmark.js">vue-benchmark.js</a>
</dd>

<dt id="dotnet-interp">dotnet-interp</dt>
<dd>
Tests <a href="https://github.com/dotnet/runtime">.NET on WebAssembly</a>. This benchmark tests operations
on .NET implementation of String, JSON serialization, specifics of .NET exceptions and computation
of a 3D scene using Mono Interpreter. Source code: <a href="wasm/dotnet">.NET</a>.
</dd>

<dt id="dotnet-aot">dotnet-aot</dt>
<dd>
Tests <a href="https://github.com/dotnet/runtime">.NET on WebAssembly</a>. This benchmark tests operations
on .NET implementation of String, JSON serialization, specifics of .NET exceptions and computation
of a 3D scene using Mono AOT. Source code: <a href="wasm/dotnet">.NET</a>.
</dd>

</dl>

<p><a href="index.html" class="button">&larr; Return to Tests</a></p>
Expand Down
5 changes: 5 additions & 0 deletions wasm/dotnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.binlog
.dotnet
.nuget
bin
obj
16 changes: 16 additions & 0 deletions wasm/dotnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .NET on WebAssembly

Tests [.NET on WebAssembly](https://github.com/dotnet/runtime). This benchmark tests operations
on .NET implementation of String, JSON serialization, specifics of .NET exceptions and computation
of a 3D scene using Mono Interpreter & AOT. Source code: [.NET](wasm/dotnet)

## Build instructions

Download .NET SDK 9.0.3xx

- [dotnet-sdk-win-x64.zip](https://aka.ms/dotnet/9.0.3xx/daily/dotnet-sdk-win-x64.zip)
- [dotnet-sdk-linux-x64.tar.gz](https://aka.ms/dotnet/9.0.3xx/daily/dotnet-sdk-linux-x64.tar.gz)

Run `build.sh` script. It will install `wasm-tools` workload & build the benchmark code twice (for Mono interpreter & AOT).

To run the benchmark code on `jsc`, we need to remove the unguarded use of `import.meta.url` in `dotnet.js`.
1 change: 1 addition & 0 deletions wasm/dotnet/aot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
globalThis.dotnetFlavor = "aot";
138 changes: 138 additions & 0 deletions wasm/dotnet/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
class Benchmark {
async init() {
const config = {
mainAssemblyName: "dotnet.dll",
globalizationMode: "custom",
assets: [
{
name: "dotnet.runtime.js",
resolvedUrl: dotnetRuntimeUrl,
moduleExports: await dynamicImport(dotnetRuntimeUrl),
behavior: "js-module-runtime"
},
{
name: "dotnet.native.js",
resolvedUrl: dotnetNativeUrl,
moduleExports: await dynamicImport(dotnetNativeUrl),
behavior: "js-module-native"
},
{
name: "dotnet.native.wasm",
resolvedUrl: wasmBinaryUrl,
buffer: await getBinary(wasmBinaryUrl),
behavior: "dotnetwasm"
},
{
name: "icudt_CJK.dat",
resolvedUrl: icuCustomUrl,
buffer: await getBinary(icuCustomUrl),
behavior: "icu"
},
{
name: "System.Collections.Concurrent.wasm",
resolvedUrl: dllCollectionsConcurrentUrl,
buffer: await getBinary(dllCollectionsConcurrentUrl),
behavior: "assembly"
},
{
name: "System.Collections.wasm",
resolvedUrl: dllCollectionsUrl,
buffer: await getBinary(dllCollectionsUrl),
behavior: "assembly"
},
{
name: "System.ComponentModel.Primitives.wasm",
resolvedUrl: dllComponentModelPrimitivesUrl,
buffer: await getBinary(dllComponentModelPrimitivesUrl),
behavior: "assembly"
},
{
name: "System.ComponentModel.TypeConverter.wasm",
resolvedUrl: dllComponentModelTypeConverterUrl,
buffer: await getBinary(dllComponentModelTypeConverterUrl),
behavior: "assembly"
},
{
name: "System.Drawing.Primitives.wasm",
resolvedUrl: dllDrawingPrimitivesUrl,
buffer: await getBinary(dllDrawingPrimitivesUrl),
behavior: "assembly"
},
{
name: "System.Drawing.wasm",
resolvedUrl: dllDrawingUrl,
buffer: await getBinary(dllDrawingUrl),
behavior: "assembly"
},
{
name: "System.IO.Pipelines.wasm",
resolvedUrl: dllIOPipelinesUrl,
buffer: await getBinary(dllIOPipelinesUrl),
behavior: "assembly"
},
{
name: "System.Linq.wasm",
resolvedUrl: dllLinqUrl,
buffer: await getBinary(dllLinqUrl),
behavior: "assembly"
},
{
name: "System.Memory.wasm",
resolvedUrl: dllMemoryUrl,
buffer: await getBinary(dllMemoryUrl),
behavior: "assembly"
},
{
name: "System.ObjectModel.wasm",
resolvedUrl: dllObjectModelUrl,
buffer: await getBinary(dllObjectModelUrl),
behavior: "assembly"
},
{
name: "System.Private.CoreLib.wasm",
resolvedUrl: dllPrivateCorelibUrl,
buffer: await getBinary(dllPrivateCorelibUrl),
behavior: "assembly",
isCore: true
},
{
name: "System.Runtime.InteropServices.JavaScript.wasm",
resolvedUrl: dllRuntimeInteropServicesJavaScriptUrl,
buffer: await getBinary(dllRuntimeInteropServicesJavaScriptUrl),
behavior: "assembly",
isCore: true
},
{
name: "System.Text.Encodings.Web.wasm",
resolvedUrl: dllTextEncodingsWebUrl,
buffer: await getBinary(dllTextEncodingsWebUrl),
behavior: "assembly"
},
{
name: "System.Text.Json.wasm",
resolvedUrl: dllTextJsonUrl,
buffer: await getBinary(dllTextJsonUrl),
behavior: "assembly"
},
{
name: "dotnet.wasm",
resolvedUrl: dllAppUrl,
buffer: await getBinary(dllAppUrl),
behavior: "assembly",
isCore: true
}
]
};

this.dotnet = (await dynamicImport(dotnetUrl)).dotnet;
this.api = await this.dotnet.withModuleConfig({ locateFile: e => e }).withConfig(config).create();
this.exports = await this.api.getAssemblyExports("dotnet.dll");

this.hardwareConcurrency = 1;
this.sceneWidth = dotnetFlavor === "aot" ? 300 : 150;
this.sceneHeight = dotnetFlavor === "aot" ? 200 : 100;
}
async runIteration() {
await this.exports.Interop.RunIteration(this.sceneWidth, this.sceneHeight, this.hardwareConcurrency);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 42 additions & 0 deletions wasm/dotnet/build-aot/wwwroot/_framework/blazor.boot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"mainAssemblyName": "dotnet",
"resources": {
"hash": "sha256-mdtA29iGB6XZvrWEaXl2AA+kfTtlB/jINgoyJI8V+N0=",
"jsModuleNative": {
"dotnet.native.js": "sha256-Ca6UeRnsgHRBtJNPbrErXmKImnD9qkhZV+u7XAPg7Kk="
},
"jsModuleRuntime": {
"dotnet.runtime.js": "sha256-x+PnWU47EIr/zL3xxqIUMDJi/dy5904TVGunDqCvjIY="
},
"wasmNative": {
"dotnet.native.wasm": "sha256-5IUs4xJpnq2JqkyYPdKn6ypYT3c+61nt1P1vvEPXo2g="
},
"icu": {
"icudt_CJK.dat": "sha256-SZLtQnRc0JkwqHab0VUVP7T3uBPSeYzxzDnpxPpUnHk=",
"icudt_EFIGS.dat": "sha256-8fItetYY8kQ0ww6oxwTLiT3oXlBwHKumbeP2pRF4yTc=",
"icudt_no_CJK.dat": "sha256-L7sV7NEYP37/Qr2FPCePo5cJqRgTXRwGHuwF5Q+0Nfs="
},
"coreAssembly": {
"dotnet.wasm": "sha256-L9ikR6noSArHMLSS5bEeP56holqZR9+98IHJDkIYQZA=",
"System.Collections.Concurrent.wasm": "sha256-t0RfwdTUubHqJjICCaVLtSx90sFWPoVRYIBQnpqEfMQ=",
"System.Collections.wasm": "sha256-74tIaxlz1VKy1ZJ4df4oWr0Qg+02hNMZMg8sM0uJR2s=",
"System.ComponentModel.Primitives.wasm": "sha256-9KlsDyYr/L+BwPCVQ2tA0tK0UoOCyGIHfd97P1s0oBE=",
"System.ComponentModel.TypeConverter.wasm": "sha256-H//PcPvC16VhrKNkarNofnzwn5WAo68J3Z340mRhrh4=",
"System.Drawing.Primitives.wasm": "sha256-bGcvJFPgMqxUOkp9q8/fhHawpRFta6Ar7ySsFIpZ9qk=",
"System.Drawing.wasm": "sha256-nb2jLiw4KDtlI4RomxyIiWcM/skfDq5jTLTqlJbXbwg=",
"System.IO.Pipelines.wasm": "sha256-LHmn3NZ0cYl/sD4s/EA26iSAYqDCycxgYdwt6suIKLM=",
"System.Linq.wasm": "sha256-eRQ2yKv3JP64KBRLvwtLwSlbppQjb762xQNooQGJHAE=",
"System.Memory.wasm": "sha256-r8Kxq0g7VCrnXJ56At7Do+nd5C+iMx+5hehlmndZ6rM=",
"System.ObjectModel.wasm": "sha256-3cKLFYajKINLJVByXBP5/Acx77qAT7PSgLMjEbwJT/Y=",
"System.Private.CoreLib.wasm": "sha256-VeHFDCz0ZLJHaMF1WXBO1dq32aqOtAxQBY7UtOYHFV4=",
"System.Runtime.InteropServices.JavaScript.wasm": "sha256-korzY+8y6mDCphxjpRx32qfUE1gK6/6D9W3cnrkRvjo=",
"System.Text.Encodings.Web.wasm": "sha256-FQmyjTLY+V+DwY398iWiXOOSDmS7cQtLg/Tc6hw2MGQ=",
"System.Text.Json.wasm": "sha256-DIIG/xiMdrqVxsRrAgOchWbwxu3ftjBvEwUqHNHpWgs="
},
"assembly": {}
},
"cacheBootResources": true,
"debugLevel": 0,
"linkerEnabled": true,
"globalizationMode": "sharded"
}
4 changes: 4 additions & 0 deletions wasm/dotnet/build-aot/wwwroot/_framework/dotnet.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions wasm/dotnet/build-aot/wwwroot/_framework/dotnet.native.js

Large diffs are not rendered by default.

Loading