Skip to content

Commit e26e460

Browse files
committed
Merge branch 'blazor_updates' of https://github.com/barahonajm/js-framework-benchmark into barahonajm-blazor_updates
2 parents 0ec3413 + c5db3e3 commit e26e460

23 files changed

+421
-62
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bundeled-dist/
2+
dotnet/
3+
obj/
4+
bin/
5+
.vs/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -JSonFile src/global.json -InstallDir ./dotnet -NoPath"
2+
powershell -NoProfile -ExecutionPolicy unrestricted -Command "./dotnet/dotnet.exe workload install wasm-tools"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --jsonfile ./src/global.json --install-dir ./dotnet --no-path
4+
./dotnet/dotnet workload install wasm-tools

frameworks/keyed/blazor-wasm-aot/package-lock.json

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "js-framework-benchmark-blazor-wasm",
3+
"version": "1.0.0",
4+
"description": "Blazor WebAssembly demo",
5+
"js-framework-benchmark": {
6+
"frameworkVersion": "6.0.1",
7+
"customURL": "/bundeled-dist/wwwroot/"
8+
},
9+
"scripts": {
10+
"install": "echo This is a no-op. && echo Due to heavy dependencies, the generated javascript is already provided. && echo If you really want to clone reflex-dom\\'s benchmark and build system use: && echo npm run install-force",
11+
"build-prod": "echo This is a no-op. && echo Due to heavy dependencies, the generated javascript is already provided. && echo If you really want to rebuild from source use: && echo npm run build-prod-force",
12+
"install-force": "run-script-os",
13+
"install-force:win32": "dotnet-install.cmd",
14+
"install-force:nix": "./dotnet-install.sh",
15+
"build-dev": "run-script-os",
16+
"build-dev:win32": "cross-env DOTNET_CLI_TELEMETRY_OPTOUT=0 ./dotnet/dotnet.exe build ./src/ -c Debug",
17+
"build-dev:nix": "cross-env DOTNET_CLI_TELEMETRY_OPTOUT=0 ./dotnet/dotnet build ./src/ -c Debug",
18+
"build-prod-force": "rimraf bundeled-dist && run-script-os",
19+
"build-prod-force:win32": "cross-env DOTNET_CLI_TELEMETRY_OPTOUT=0 ./dotnet/dotnet.exe publish ./src/ -c Release -o ./bundeled-dist",
20+
"build-prod-force:nix": "cross-env DOTNET_CLI_TELEMETRY_OPTOUT=0 ./dotnet/dotnet publish ./src/ -c Release -o ./bundeled-dist"
21+
},
22+
"keywords": [
23+
"blazor",
24+
"webassembly",
25+
"aot"
26+
],
27+
"author": "Juan Barahona",
28+
"license": "Apache-2.0",
29+
"homepage": "https://github.com/krausest/js-framework-benchmark",
30+
"repository": {
31+
"type": "git",
32+
"url": "https://github.com/krausest/js-framework-benchmark.git"
33+
},
34+
"dependencies": {
35+
},
36+
"devDependencies": {
37+
"rimraf": "^3.0.2",
38+
"cross-env": "^7.0.2",
39+
"run-script-os": "1.1.1"
40+
}
41+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@namespace blazor_wasm
2+
3+
<div class="container">
4+
<div class="jumbotron">
5+
<div class="row">
6+
<div class="col-md-6">
7+
<h1>Blazor-WASM-AOT-"keyed"</h1>
8+
</div>
9+
<div class="col-md-6">
10+
<div class="row">
11+
<div class="col-sm-6 smallpad">
12+
<button type='button' class='btn btn-primary btn-block' id='run' @onclick="Run">Create 1,000 rows</button>
13+
</div>
14+
<div class="col-sm-6 smallpad">
15+
<button type='button' class='btn btn-primary btn-block' id='runlots' @onclick="Runlots">Create 10,000 rows</button>
16+
</div>
17+
<div class="col-sm-6 smallpad">
18+
<button type='button' class='btn btn-primary btn-block' id='add' @onclick="Add">Append 1,000 rows</button>
19+
</div>
20+
<div class="col-sm-6 smallpad">
21+
<button type='button' class='btn btn-primary btn-block' id='update' @onclick="Update">Update every 10th row</button>
22+
</div>
23+
<div class="col-sm-6 smallpad">
24+
<button type='button' class='btn btn-primary btn-block' id='clear' @onclick="Clear">Clear</button>
25+
</div>
26+
<div class="col-sm-6 smallpad">
27+
<button type='button' class='btn btn-primary btn-block' id='swaprows' @onclick="SwapRows">Swap Rows</button>
28+
</div>
29+
</div>
30+
</div>
31+
</div>
32+
</div>
33+
<table class="table table-hover table-striped test-data">
34+
<tbody id="tbody">
35+
@foreach (var item in Data)
36+
{
37+
<tr @key="item.Id" class="@((item.Id == Selected ? "danger" : ""))">
38+
<td class="col-md-1">@item.Id</td>
39+
<td class="col-md-4">
40+
<a href="#" @onclick="item.Select" @onclick:preventDefault>
41+
@item.Label
42+
</a>
43+
</td>
44+
<td class="col-md-1">
45+
<a href="#" @onclick="item.Remove" @onclick:preventDefault>
46+
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
47+
</a>
48+
</td>
49+
<td class="col-md-6"></td>
50+
</tr>
51+
}
52+
</tbody>
53+
</table>
54+
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
55+
</div>
56+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
namespace blazor_wasm
2+
{
3+
public partial class App
4+
{
5+
public List<Data> Data { get; set; } = new();
6+
public int Selected { get; set; }
7+
8+
private readonly string[] adjectives = new string[]
9+
{
10+
"pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"
11+
};
12+
13+
private readonly string[] colours = new string[]
14+
{
15+
"red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"
16+
};
17+
18+
private readonly string[] nouns = new string[]
19+
{
20+
"table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"
21+
};
22+
23+
private int _rowId = 1;
24+
25+
List<Data> BuildData(int count = 1000)
26+
{
27+
List<Data> result = new(count);
28+
for (int i = 0; i < count; i++)
29+
{
30+
Data data = new()
31+
{
32+
Id = _rowId++,
33+
Label = $"{adjectives[Random.Shared.Next(adjectives.Length)]} {colours[Random.Shared.Next(colours.Length)]} {nouns[Random.Shared.Next(nouns.Length)]}",
34+
};
35+
36+
data.Select = (e) => Select(data);
37+
data.Remove = (e) => Remove(data);
38+
result.Add(data);
39+
}
40+
41+
return result;
42+
}
43+
44+
public void Select(Data item)
45+
{
46+
Selected = item.Id;
47+
}
48+
49+
void Remove(Data item)
50+
{
51+
Data.Remove(item);
52+
}
53+
54+
void Run()
55+
{
56+
Data = BuildData();
57+
}
58+
void Runlots()
59+
{
60+
Data = BuildData(10000);
61+
}
62+
void Add()
63+
{
64+
Data.AddRange(BuildData(1000));
65+
}
66+
void Update()
67+
{
68+
for (var i = 0; i < Data.Count; i += 10)
69+
{
70+
Data[i].Label += " !!!";
71+
}
72+
}
73+
void Clear()
74+
{
75+
Data.Clear();
76+
Selected = 0;
77+
}
78+
void SwapRows()
79+
{
80+
if (Data.Count > 998)
81+
{
82+
var a = Data[1];
83+
Data[1] = Data[998];
84+
Data[998] = a;
85+
}
86+
}
87+
}
88+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.AspNetCore.Components.Web;
2+
3+
namespace blazor_wasm
4+
{
5+
public class Data
6+
{
7+
public int Id { get; set; } = default!;
8+
public string Label { get; set; } = default!;
9+
10+
public Action<MouseEventArgs> Remove { get; set; } = default!;
11+
public Action<MouseEventArgs> Select { get; set; } = default!;
12+
}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using blazor_wasm;
2+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
3+
4+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
5+
builder.RootComponents.Add<App>("app");
6+
7+
await builder.Build().RunAsync();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:33030",
7+
"sslPort": 44363
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
15+
"environmentVariables": {
16+
"ASPNETCORE_ENVIRONMENT": "Development"
17+
}
18+
},
19+
"blazor-wasm": {
20+
"commandName": "Project",
21+
"launchBrowser": true,
22+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
23+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
24+
"environmentVariables": {
25+
"ASPNETCORE_ENVIRONMENT": "Development"
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)