Skip to content

Commit c144a2c

Browse files
committed
perf: use worst-case scenario for benches
1 parent a179de0 commit c144a2c

34 files changed

Lines changed: 1129 additions & 1502 deletions

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Changelog
22

3-
## Unreleased
3+
## 2026-06-10 - v1.6.0
44

5-
- bench/charts: charts with a sparse extreme throughput tail now switch their measured axis to a log10 scale so ordinary values remain readable without clipping any result. The detector combines Tukey's far-outlier fence with median absolute deviation and requires a clearly separated upper tail; charts without extreme outliers remain linear. Classic-payload serialization always uses log10 because its JSON.Obj series is a distinct, much faster population
5+
- perf: much faster deserialization. uses default values as cache.
66

77
## 2026-06-10 - v1.5.0
88

assembly/__benches__/classic/canada.bench.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { expect } from "../../__tests__/lib";
33
import {
44
blackbox,
55
bench,
6-
ChangingPayloads,
76
dumpToFile,
87
readFile,
98
utf8ByteLength,
@@ -12,29 +11,29 @@ import {
1211

1312
@json
1413
class CanadaProperties {
15-
name: string = "";
14+
name!: string;
1615
}
1716

1817

1918
@json
2019
class CanadaGeometry {
21-
type: string = "";
22-
coordinates: Array<Array<Array<f64>>> = [];
20+
type!: string;
21+
coordinates!: Array<Array<Array<f64>>>;
2322
}
2423

2524

2625
@json
2726
class CanadaFeature {
28-
type: string = "";
29-
properties: CanadaProperties = new CanadaProperties();
30-
geometry: CanadaGeometry = new CanadaGeometry();
27+
type!: string;
28+
properties!: CanadaProperties;
29+
geometry!: CanadaGeometry;
3130
}
3231

3332

3433
@json
3534
class Canada {
36-
type: string = "";
37-
features: Array<CanadaFeature> = [];
35+
type!: string;
36+
features!: Array<CanadaFeature>;
3837
}
3938

4039
const prettyJson = readFile(
@@ -46,14 +45,12 @@ expect(JSON.stringify(JSON.parse<Canada>(prettyJson))).toBe(minJson);
4645
expect(JSON.stringify(JSON.parse<Canada>(minJson))).toBe(minJson);
4746

4847
const canada = JSON.parse<Canada>(prettyJson);
49-
const prettyPayloads = new ChangingPayloads(prettyJson);
50-
const minPayloads = new ChangingPayloads(minJson);
5148
const out = "";
5249

5350
bench(
5451
"Deserialize Canada (pretty)",
5552
() => {
56-
blackbox(JSON.parse<Canada>(prettyPayloads.next()));
53+
blackbox(JSON.parse<Canada>(prettyJson));
5754
},
5855
500,
5956
utf8ByteLength(prettyJson),
@@ -63,7 +60,7 @@ dumpToFile("canada-pretty", "deserialize");
6360
bench(
6461
"Deserialize Canada (min)",
6562
() => {
66-
blackbox(JSON.parse<Canada>(minPayloads.next()));
63+
blackbox(JSON.parse<Canada>(minJson));
6764
},
6865
500,
6966
utf8ByteLength(minJson),

assembly/__benches__/classic/canada.lazy.bench.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ import {
1313

1414
@json({ lazy: "auto" })
1515
class CanadaProperties {
16-
name: string = "";
16+
name!: string;
1717
}
1818

1919

2020
@json({ lazy: "auto" })
2121
class CanadaGeometry {
22-
type: string = "";
23-
coordinates: Array<Array<Array<f64>>> = [];
22+
type!: string;
23+
coordinates!: Array<Array<Array<f64>>>;
2424
}
2525

2626

2727
@json({ lazy: "auto" })
2828
class CanadaFeature {
29-
type: string = "";
30-
properties: CanadaProperties = new CanadaProperties();
31-
geometry: CanadaGeometry = new CanadaGeometry();
29+
type!: string;
30+
properties!: CanadaProperties;
31+
geometry!: CanadaGeometry;
3232
}
3333

3434

3535
@json({ lazy: "auto" })
3636
class Canada {
37-
type: string = "";
38-
features: Array<CanadaFeature> = [];
37+
type!: string;
38+
features!: Array<CanadaFeature>;
3939
}
4040

4141
function touchRoot(root: Canada): f64 {

assembly/__benches__/classic/citm_catalog.bench.ts

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { expect } from "../../__tests__/lib";
33
import {
44
blackbox,
55
bench,
6-
ChangingPayloads,
76
dumpToFile,
87
readFile,
98
utf8ByteLength,
@@ -16,66 +15,66 @@ import {
1615

1716
@json
1817
class Price {
19-
amount: i64 = 0;
20-
audienceSubCategoryId: i64 = 0;
21-
seatCategoryId: i64 = 0;
18+
amount!: i64;
19+
audienceSubCategoryId!: i64;
20+
seatCategoryId!: i64;
2221
}
2322

2423

2524
@json
2625
class Area {
27-
areaId: i64 = 0;
28-
blockIds: i64[] = [];
26+
areaId!: i64;
27+
blockIds!: i64[];
2928
}
3029

3130

3231
@json
3332
class SeatCategory {
34-
areas: Area[] = [];
35-
seatCategoryId: i64 = 0;
33+
areas!: Area[];
34+
seatCategoryId!: i64;
3635
}
3736

3837

3938
@json
4039
class Performance {
41-
eventId: i64 = 0;
42-
id: i64 = 0;
43-
logo: string | null = null;
44-
name: string | null = null;
45-
prices: Price[] = [];
46-
seatCategories: SeatCategory[] = [];
47-
seatMapImage: string | null = null;
48-
start: i64 = 0;
49-
venueCode: string = "";
40+
eventId!: i64;
41+
id!: i64;
42+
logo!: string | null;
43+
name!: string | null;
44+
prices!: Price[];
45+
seatCategories!: SeatCategory[];
46+
seatMapImage!: string | null;
47+
start!: i64;
48+
venueCode!: string;
5049
}
5150

5251

5352
@json
5453
class CitmEvent {
55-
description: string | null = null;
56-
id: i64 = 0;
57-
logo: string | null = null;
58-
name: string = "";
59-
subTopicIds: i64[] = [];
60-
subjectCode: string | null = null;
61-
subtitle: string | null = null;
62-
topicIds: i64[] = [];
54+
description!: string | null;
55+
id!: i64;
56+
logo!: string | null;
57+
name!: string;
58+
subTopicIds!: i64[];
59+
subjectCode!: string | null;
60+
subtitle!: string | null;
61+
topicIds!: i64[];
6362
}
6463

6564

6665
@json
6766
class Citm {
68-
areaNames: Map<string, string> = new Map<string, string>();
69-
audienceSubCategoryNames: Map<string, string> = new Map<string, string>();
70-
blockNames: Map<string, string> = new Map<string, string>();
71-
events: Map<string, CitmEvent> = new Map<string, CitmEvent>();
72-
performances: Performance[] = [];
73-
seatCategoryNames: Map<string, string> = new Map<string, string>();
74-
subTopicNames: Map<string, string> = new Map<string, string>();
75-
subjectNames: Map<string, string> = new Map<string, string>();
76-
topicNames: Map<string, string> = new Map<string, string>();
77-
topicSubTopics: Map<string, i64[]> = new Map<string, i64[]>();
78-
venueNames: Map<string, string> = new Map<string, string>();
67+
areaNames!: Map<string, string>;
68+
audienceSubCategoryNames!: Map<string, string>;
69+
blockNames!: Map<string, string>;
70+
events!: Map<string, CitmEvent>;
71+
performances!: Performance[];
72+
seatCategoryNames!: Map<string, string>;
73+
subTopicNames!: Map<string, string>;
74+
subjectNames!: Map<string, string>;
75+
topicNames!: Map<string, string>;
76+
topicSubTopics!: Map<string, i64[]>;
77+
venueNames!: Map<string, string>;
7978
}
8079

8180
const prettyJson = readFile(
@@ -88,14 +87,12 @@ const minJson = readFile(
8887
expect(JSON.parse<Citm>(minJson).performances.length).toBe(243);
8988

9089
const citm = JSON.parse<Citm>(prettyJson);
91-
const prettyPayloads = new ChangingPayloads(prettyJson);
92-
const minPayloads = new ChangingPayloads(minJson);
9390
const out = "";
9491

9592
bench(
9693
"Deserialize CITM (pretty)",
9794
() => {
98-
blackbox(JSON.parse<Citm>(prettyPayloads.next()));
95+
blackbox(JSON.parse<Citm>(prettyJson));
9996
},
10097
2000,
10198
utf8ByteLength(prettyJson),
@@ -105,7 +102,7 @@ dumpToFile("citm_catalog-pretty", "deserialize");
105102
bench(
106103
"Deserialize CITM (min)",
107104
() => {
108-
blackbox(JSON.parse<Citm>(minPayloads.next()));
105+
blackbox(JSON.parse<Citm>(minJson));
109106
},
110107
2000,
111108
utf8ByteLength(minJson),

assembly/__benches__/classic/citm_catalog.lazy.bench.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,66 +17,66 @@ import {
1717

1818
@json({ lazy: "auto" })
1919
class Price {
20-
amount: i64 = 0;
21-
audienceSubCategoryId: i64 = 0;
22-
seatCategoryId: i64 = 0;
20+
amount!: i64;
21+
audienceSubCategoryId!: i64;
22+
seatCategoryId!: i64;
2323
}
2424

2525

2626
@json({ lazy: "auto" })
2727
class Area {
28-
areaId: i64 = 0;
29-
blockIds: i64[] = [];
28+
areaId!: i64;
29+
blockIds!: i64[];
3030
}
3131

3232

3333
@json({ lazy: "auto" })
3434
class SeatCategory {
35-
areas: Area[] = [];
36-
seatCategoryId: i64 = 0;
35+
areas!: Area[];
36+
seatCategoryId!: i64;
3737
}
3838

3939

4040
@json({ lazy: "auto" })
4141
class Performance {
42-
eventId: i64 = 0;
43-
id: i64 = 0;
44-
logo: string | null = null;
45-
name: string | null = null;
46-
prices: Price[] = [];
47-
seatCategories: SeatCategory[] = [];
48-
seatMapImage: string | null = null;
49-
start: i64 = 0;
50-
venueCode: string = "";
42+
eventId!: i64;
43+
id!: i64;
44+
logo!: string | null;
45+
name!: string | null;
46+
prices!: Price[];
47+
seatCategories!: SeatCategory[];
48+
seatMapImage!: string | null;
49+
start!: i64;
50+
venueCode!: string;
5151
}
5252

5353

5454
@json({ lazy: "auto" })
5555
class CitmEvent {
56-
description: string | null = null;
57-
id: i64 = 0;
58-
logo: string | null = null;
59-
name: string = "";
60-
subTopicIds: i64[] = [];
61-
subjectCode: string | null = null;
62-
subtitle: string | null = null;
63-
topicIds: i64[] = [];
56+
description!: string | null;
57+
id!: i64;
58+
logo!: string | null;
59+
name!: string;
60+
subTopicIds!: i64[];
61+
subjectCode!: string | null;
62+
subtitle!: string | null;
63+
topicIds!: i64[];
6464
}
6565

6666

6767
@json({ lazy: "auto" })
6868
class Citm {
69-
areaNames: Map<string, string> = new Map<string, string>();
70-
audienceSubCategoryNames: Map<string, string> = new Map<string, string>();
71-
blockNames: Map<string, string> = new Map<string, string>();
72-
events: Map<string, CitmEvent> = new Map<string, CitmEvent>();
73-
performances: Performance[] = [];
74-
seatCategoryNames: Map<string, string> = new Map<string, string>();
75-
subTopicNames: Map<string, string> = new Map<string, string>();
76-
subjectNames: Map<string, string> = new Map<string, string>();
77-
topicNames: Map<string, string> = new Map<string, string>();
78-
topicSubTopics: Map<string, i64[]> = new Map<string, i64[]>();
79-
venueNames: Map<string, string> = new Map<string, string>();
69+
areaNames!: Map<string, string>;
70+
audienceSubCategoryNames!: Map<string, string>;
71+
blockNames!: Map<string, string>;
72+
events!: Map<string, CitmEvent>;
73+
performances!: Performance[];
74+
seatCategoryNames!: Map<string, string>;
75+
subTopicNames!: Map<string, string>;
76+
subjectNames!: Map<string, string>;
77+
topicNames!: Map<string, string>;
78+
topicSubTopics!: Map<string, i64[]>;
79+
venueNames!: Map<string, string>;
8080
}
8181

8282
function touchRoot(root: Citm): f64 {

0 commit comments

Comments
 (0)