Skip to content

Commit ba08d60

Browse files
authored
Update names and descriptions for benchmarks (#18430)
1 parent 419a1f1 commit ba08d60

File tree

7 files changed

+89
-15
lines changed

7 files changed

+89
-15
lines changed

src/Components/benchmarkapps/Wasm.Performance/Driver/BenchmarkResult.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@ class BenchmarkResult
44
{
55
public string Name { get; set; }
66

7+
public BenchmarkDescriptor Descriptor { get; set; }
8+
9+
public string ShortDescription { get; set; }
10+
711
public bool Success { get; set; }
812

913
public int NumExecutions { get; set; }
1014

1115
public double Duration { get; set; }
16+
17+
public class BenchmarkDescriptor
18+
{
19+
public string Name { get; set; }
20+
21+
public string Description { get; set; }
22+
}
1223
}
1324
}

src/Components/benchmarkapps/Wasm.Performance/Driver/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ private static void FormatAsBenchmarksOutput(List<BenchmarkResult> results)
7676
output.Metadata.Add(new BenchmarkMetadata
7777
{
7878
Source = "BlazorWasm",
79-
Name = result.Name,
80-
ShortDescription = $"{result.Name} Duration",
81-
LongDescription = $"{result.Name} Duration",
79+
Name = result.Descriptor.Name,
80+
ShortDescription = result.Name,
81+
LongDescription = result.Descriptor.Description,
8282
Format = "n2"
8383
});
8484

@@ -94,7 +94,7 @@ private static void FormatAsBenchmarksOutput(List<BenchmarkResult> results)
9494
output.Metadata.Add(new BenchmarkMetadata
9595
{
9696
Source = "BlazorWasm",
97-
Name = "Publish size",
97+
Name = "blazorwasm/publish-size",
9898
ShortDescription = "Publish size (KB)",
9999
LongDescription = "Publish size (KB)",
100100
Format = "n2",
@@ -116,7 +116,7 @@ private static void FormatAsBenchmarksOutput(List<BenchmarkResult> results)
116116
output.Metadata.Add(new BenchmarkMetadata
117117
{
118118
Source = "BlazorWasm",
119-
Name = "Publish size (compressed)",
119+
Name = "blazorwasm/compressed-publish-size",
120120
ShortDescription = "Publish size compressed app (KB)",
121121
LongDescription = "Publish size - compressed app (KB)",
122122
Format = "n2",

src/Components/benchmarkapps/Wasm.Performance/TestApp/wwwroot/benchmarks/appStartup.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ group('App Startup', () => {
1010
} finally {
1111
app.dispose();
1212
}
13+
}, {
14+
descriptor: {
15+
name: "blazorwasm/time-to-first-ui",
16+
description: "Time to render first UI (ms)"
17+
}
1318
});
1419

1520
});

src/Components/benchmarkapps/Wasm.Performance/TestApp/wwwroot/benchmarks/jsonHandling.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,59 @@ group('JSON handling', () => {
1616
teardown(() => app.dispose());
1717

1818
benchmark('Serialize 1kb', () =>
19-
benchmarkJson(app, '#serialize-small', '#serialized-length', 935));
19+
benchmarkJson(app, '#serialize-small', '#serialized-length', 935), {
20+
descriptor: {
21+
name: 'blazorwasm/jsonserialize-1kb',
22+
description: 'Serialize JSON 1kb - Time in ms'
23+
}
24+
});
2025

2126
benchmark('Serialize 340kb', () =>
22-
benchmarkJson(app, '#serialize-large', '#serialized-length', 339803));
27+
benchmarkJson(app, '#serialize-large', '#serialized-length', 339803), {
28+
descriptor: {
29+
name: 'blazorwasm/jsonserialize-340kb',
30+
description: 'Serialize JSON 340kb - Time in ms'
31+
}
32+
});
2333

2434
benchmark('Deserialize 1kb', () =>
25-
benchmarkJson(app, '#deserialize-small', '#deserialized-count', 5));
35+
benchmarkJson(app, '#deserialize-small', '#deserialized-count', 5), {
36+
descriptor: {
37+
name: 'blazorwasm/jsondeserialize-1kb',
38+
description: 'Deserialize JSON 1kb - Time in ms'
39+
}
40+
});
2641

2742
benchmark('Deserialize 340kb', () =>
28-
benchmarkJson(app, '#deserialize-large', '#deserialized-count', 1365));
43+
benchmarkJson(app, '#deserialize-large', '#deserialized-count', 1365), {
44+
descriptor: {
45+
name: 'blazorwasm/jsondeserialize-340kb',
46+
description: 'Deserialize JSON 340kb - Time in ms'
47+
}
48+
});
2949

3050
benchmark('Serialize 340kb (JavaScript)', () => {
3151
const json = JSON.stringify(largeObjectToSerialize);
3252
if (json.length !== 339803) {
3353
throw new Error(`Incorrect length: ${json.length}`);
3454
}
55+
}, {
56+
descriptor: {
57+
name: 'blazorwasm/jsonserialize-javascript-340kb',
58+
description: 'Serialize JSON 340kb using JavaScript - Time in ms'
59+
}
3560
});
3661

3762
benchmark('Deserialize 340kb (JavaScript)', () => {
3863
const parsed = JSON.parse(largeJsonToDeserialize);
3964
if (parsed.name !== 'CEO - Subordinate 0') {
4065
throw new Error('Incorrect result');
4166
}
67+
}, {
68+
descriptor: {
69+
name: 'blazorwasm/jsondeserialize-javascript-340kb',
70+
description: 'Deserialize JSON 340kb using JavaScript - Time in ms'
71+
}
4272
});
4373
});
4474

src/Components/benchmarkapps/Wasm.Performance/TestApp/wwwroot/benchmarks/lib/minibench/minibench.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class Benchmark extends EventEmitter {
165165
this._group = group;
166166
this.name = name;
167167
this._fn = fn;
168-
this._options = options;
168+
this._options = options || {};
169169
this._state = { status: BenchmarkStatus.idle };
170170
}
171171

@@ -205,13 +205,23 @@ class Benchmark extends EventEmitter {
205205
await this._group.runTeardown();
206206
}
207207

208-
reportBenchmarkEvent(BenchmarkEvent.benchmarkCompleted, { 'name': this.name, success: true, numExecutions: this._state.numExecutions, duration: this._state.estimatedExecutionDurationMs });
208+
reportBenchmarkEvent(BenchmarkEvent.benchmarkCompleted, {
209+
name: this.name,
210+
success: true,
211+
numExecutions: this._state.numExecutions,
212+
duration: this._state.estimatedExecutionDurationMs,
213+
descriptor: this._options.descriptor
214+
});
209215

210216
this._updateState({ status: BenchmarkStatus.idle });
211217
} catch (ex) {
212218
this._updateState({ status: BenchmarkStatus.error });
213219
console.error(ex);
214-
reportBenchmarkEvent(BenchmarkEvent.benchmarkError, { 'name': this.name, success: false });
220+
reportBenchmarkEvent(BenchmarkEvent.benchmarkError, {
221+
name: this.name,
222+
success: false,
223+
descriptor: this._options.descriptor
224+
});
215225
}
216226
});
217227
}

src/Components/benchmarkapps/Wasm.Performance/TestApp/wwwroot/benchmarks/renderList.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,24 @@ group('Rendering list', () => {
1616
app.dispose();
1717
});
1818

19-
benchmark('Render 10 items', () => measureRenderList(app, 10));
20-
benchmark('Render 100 items', () => measureRenderList(app, 100));
21-
benchmark('Render 1000 items', () => measureRenderList(app, 1000));
19+
benchmark('Render 10 items', () => measureRenderList(app, 10), {
20+
descriptor: {
21+
name: 'blazorwasm/render-10-items',
22+
description: 'Time to render 10 item list (ms)'
23+
}
24+
});
25+
benchmark('Render 100 items', () => measureRenderList(app, 100), {
26+
descriptor: {
27+
name: 'blazorwasm/render-100-items',
28+
description: 'Time to render 100 item list (ms)'
29+
}
30+
});
31+
benchmark('Render 1000 items', () => measureRenderList(app, 1000), {
32+
descriptor: {
33+
name: 'blazorwasm/render-1000-items',
34+
description: 'Time to render 1000 item list (ms)'
35+
}
36+
});
2237

2338
});
2439

src/Components/benchmarkapps/Wasm.Performance/benchmarks.compose.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"branchOrCommit": "blazor-wasm",
1515
"dockerfile": "src/Components/benchmarkapps/Wasm.Performance/dockerfile"
1616
},
17+
"buildArguments": [
18+
"gitBranch=blazor-wasm"
19+
],
1720
"waitForExit": true,
1821
"readyStateText": "Application started."
1922
}

0 commit comments

Comments
 (0)