Skip to content

Commit 06d5f59

Browse files
committed
Merge branch 'johanndev-master'
2 parents 5c60366 + 20311b4 commit 06d5f59

File tree

16 files changed

+307
-3
lines changed

16 files changed

+307
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist/
2+
dotnet/
3+
obj/
4+
bin/
5+
.vs/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
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
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "js-framework-benchmark-blazor-wasm",
3+
"version": "1.0.0",
4+
"description": "Blazor WebAssembly demo",
5+
"js-framework-benchmark": {
6+
"frameworkVersion": "3.2.0-preview4.20210.8",
7+
"customURL": "/dist/wwwroot/"
8+
},
9+
"scripts": {
10+
"postinstall": "run-script-os",
11+
"postinstall:win32": "dotnet-install.cmd",
12+
"postinstall:nix": "./dotnet-install.sh",
13+
"build-dev": "run-script-os",
14+
"build-dev:win32": "cross-env DOTNET_CLI_TELEMETRY_OPTOUT=0 ./dotnet/dotnet.exe build ./src/ -c Debug",
15+
"build-dev:nix": "cross-env DOTNET_CLI_TELEMETRY_OPTOUT=0 ./dotnet/dotnet build ./src/ -c Debug",
16+
"build-prod": "run-script-os",
17+
"build-prod:win32": "cross-env DOTNET_CLI_TELEMETRY_OPTOUT=0 ./dotnet/dotnet.exe publish ./src/ -c Release -o ./dist",
18+
"build-prod:nix": "cross-env DOTNET_CLI_TELEMETRY_OPTOUT=0 ./dotnet/dotnet publish ./src/ -c Release -o ./dist"
19+
},
20+
"keywords": [
21+
"blazor",
22+
"webassembly"
23+
],
24+
"author": "Stefan Krause",
25+
"license": "Apache-2.0",
26+
"homepage": "https://github.com/krausest/js-framework-benchmark",
27+
"repository": {
28+
"type": "git",
29+
"url": "https://github.com/krausest/js-framework-benchmark.git"
30+
},
31+
"dependencies": {},
32+
"devDependencies": {
33+
"cross-env": "^7.0.2",
34+
"run-script-os": "1.1.1"
35+
}
36+
}
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-"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="(_ => Select(item))" @onclick:preventDefault>
41+
@item.Label
42+
</a>
43+
</td>
44+
<td class="col-md-1">
45+
<a href="#" @onclick="(_ => Delete(item))" @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+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
5+
namespace blazor_wasm
6+
{
7+
public partial class App
8+
{
9+
List<Data> data = new List<Data>();
10+
int selected;
11+
int id = 1;
12+
Random random = new Random(0);
13+
14+
string[] adjectives = new string[]
15+
{
16+
"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"
17+
};
18+
19+
string[] colours = new string[]
20+
{
21+
"red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"
22+
};
23+
24+
string[] nouns = new string[]
25+
{
26+
"table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"
27+
};
28+
29+
List<Data> BuildData(int count = 1000)
30+
{
31+
var result = new List<Data>();
32+
for (int i = 0; i < count; i++)
33+
{
34+
result.Add(new Data
35+
{
36+
Id = this.id++,
37+
Label = adjectives[this.random.Next(adjectives.Length)] + " " + colours[this.random.Next(colours.Length)] + " " + nouns[this.random.Next(nouns.Length)]
38+
});
39+
}
40+
41+
return result;
42+
}
43+
44+
public void Select(Data item)
45+
{
46+
this.selected = item.Id;
47+
}
48+
49+
void Delete(Data item)
50+
{
51+
this.data.Remove(item);
52+
}
53+
54+
void Run()
55+
{
56+
this.data = this.BuildData();
57+
}
58+
void Runlots()
59+
{
60+
this.data = this.BuildData(10000);
61+
}
62+
void Add()
63+
{
64+
this.data.AddRange(this.BuildData(1000));
65+
}
66+
void Update()
67+
{
68+
for (var i = 0; i < this.data.Count; i += 10)
69+
{
70+
this.data[i].Label += " !!!";
71+
}
72+
}
73+
void Clear()
74+
{
75+
this.data = new List<Data>();
76+
this.selected = 0;
77+
}
78+
void SwapRows()
79+
{
80+
if (this.data.Count > 998)
81+
{
82+
var a = this.data[1];
83+
this.data[1] = this.data[998];
84+
this.data[998] = a;
85+
}
86+
}
87+
}
88+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace blazor_wasm
2+
{
3+
public class Data
4+
{
5+
public int Id { get; set; }
6+
public string Label { get; set; }
7+
}
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Threading.Tasks;
2+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
3+
4+
namespace blazor_wasm
5+
{
6+
public class Program
7+
{
8+
public static async Task Main(string[] args)
9+
{
10+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
11+
builder.RootComponents.Add<App>("app");
12+
13+
await builder.Build().RunAsync();
14+
}
15+
}
16+
}
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+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@using System.Net.Http
2+
@using System.Net.Http.Json
3+
@using Microsoft.AspNetCore.Components.Forms
4+
@using Microsoft.AspNetCore.Components.Routing
5+
@using Microsoft.AspNetCore.Components.Web
6+
@using Microsoft.JSInterop
7+
@using blazor_wasm
8+

0 commit comments

Comments
 (0)