Skip to content

Commit d8683e3

Browse files
committed
Tidy up
1 parent 3bffd00 commit d8683e3

File tree

5 files changed

+11
-62
lines changed

5 files changed

+11
-62
lines changed

tests/performance/app/routes/update-with-same-state-m2m.js

-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// FIXME: Don't merge disables
2-
/* eslint-disable no-console */
3-
/* eslint-disable no-undef */
41
import Route from '@ember/routing/route';
52
import { inject as service } from '@ember/service';
63

@@ -10,7 +7,6 @@ export default Route.extend({
107
store: service(),
118

129
async model() {
13-
console.groupCollapsed('test-setup');
1410
performance.mark('start-data-generation');
1511

1612
const initialPayload = await fetch('./fixtures/big-many-to-many.json').then((r) => r.json());
@@ -33,39 +29,22 @@ export default Route.extend({
3329
peekedCars.forEach((car) => iterateCar(car, seen));
3430
const removedColors = [];
3531

36-
console.groupEnd();
37-
console.log(structuredClone(getWarpDriveMetricCounts()));
38-
3932
performance.mark('start-local-removal');
40-
console.groupCollapsed('start-local-removal');
4133
for (const car of peekedCars) {
4234
const colors = car.colors;
4335
removedColors.push(colors.splice(0, REMOVAL_COUNT));
4436
}
4537

46-
console.groupEnd();
47-
console.log(structuredClone(getWarpDriveMetricCounts()));
48-
4938
performance.mark('start-push-minus-one-payload');
50-
console.groupCollapsed('start-push-minus-one-payload');
5139
this.store.push(payloadWithRemoval);
52-
console.groupEnd();
53-
console.log(structuredClone(getWarpDriveMetricCounts()));
5440

5541
performance.mark('start-local-addition');
56-
console.groupCollapsed('start-local-addition');
5742
peekedCars.forEach((car, index) => {
5843
car.colors = removedColors[index].concat(car.colors);
5944
});
6045

61-
console.groupEnd();
62-
console.log(structuredClone(getWarpDriveMetricCounts()));
63-
6446
performance.mark('start-push-plus-one-payload');
65-
console.groupCollapsed('start-push-plus-one-payload');
6647
this.store.push(initialPayload2);
67-
console.groupEnd();
68-
console.log(structuredClone(getWarpDriveMetricCounts()));
6948

7049
performance.mark('end-push-plus-one-payload');
7150
},

tests/performance/app/routes/update-with-same-state.js

+2-33
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ export default Route.extend({
55
store: service(),
66

77
async model() {
8-
console.groupCollapsed('test-setup');
98
performance.mark('start-data-generation');
109

1110
const initialPayload = await fetch('./fixtures/add-children-initial.json').then((r) => r.json());
1211
const initialPayload2 = structuredClone(initialPayload);
13-
14-
const payloadWithRemoval = structuredClone(initialPayload);
15-
payloadWithRemoval.data.relationships.children.data.splice(0, 19000);
16-
payloadWithRemoval.included.splice(0, 19000);
12+
const payloadWithRemoval = await fetch('./fixtures/add-children-with-removal.json').then((r) => r.json());
1713

1814
performance.mark('start-push-initial-payload');
1915
this.store.push(initialPayload);
@@ -32,56 +28,29 @@ export default Route.extend({
3228
const parent = peekedParents[0];
3329
const children = await parent.children;
3430

35-
await logChildren(parent);
36-
console.groupEnd();
37-
console.log(structuredClone(getWarpDriveMetricCounts()));
38-
3931
performance.mark('start-local-removal');
40-
console.groupCollapsed('start-local-removal');
4132
const removedChildren = children.splice(0, 19000);
42-
await logChildren(parent);
43-
console.groupEnd();
44-
console.log(structuredClone(getWarpDriveMetricCounts()));
4533

4634
performance.mark('start-push-minus-one-payload');
47-
console.groupCollapsed('start-push-minus-one-payload');
4835
this.store.push(payloadWithRemoval);
49-
await logChildren(parent);
50-
console.groupEnd();
51-
console.log(structuredClone(getWarpDriveMetricCounts()));
5236

5337
performance.mark('start-local-addition');
54-
console.groupCollapsed('start-local-addition');
5538
parent.children = removedChildren.concat(children);
56-
await logChildren(parent);
57-
console.groupEnd();
58-
console.log(structuredClone(getWarpDriveMetricCounts()));
5939

6040
performance.mark('start-push-plus-one-payload');
61-
console.groupCollapsed('start-push-plus-one-payload');
6241
this.store.push(initialPayload2);
63-
await logChildren(parent);
64-
console.groupEnd();
65-
console.log(structuredClone(getWarpDriveMetricCounts()));
6642

6743
performance.mark('end-push-plus-one-payload');
6844
},
6945
});
7046

71-
async function logChildren(parent) {
72-
const children = await parent.children;
73-
console.log(
74-
`children is an array of length ${children.length} of ids ${children.at(0).id}..${children.at(children.length - 1).id}`
75-
);
76-
}
77-
7847
function iterateChild(record, seen) {
7948
if (seen.has(record)) {
8049
return;
8150
}
8251
seen.add(record);
8352

84-
record.parent.get('name');
53+
record.parent;
8554
}
8655

8756
function iterateParent(record, seen) {
Binary file not shown.

tests/performance/fixtures/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
3-
Run this file with `bun run ./fixtures/index.js` to generate the fixtures for the performance benchmarks.
4-
5-
*/
6-
71
const fs = require('fs');
82
const zlib = require('zlib');
93

@@ -34,8 +28,14 @@ const createParentRecords = require('./create-parent-records');
3428
const { createComplexPayload: createComplexRecordsPayload } = require('./create-complex-payload.ts');
3529

3630
async function main() {
37-
write('add-children-initial', createParentPayload(19600));
31+
const initialChildrenPayload = createParentPayload(19600);
32+
write('add-children-initial', initialChildrenPayload);
3833
write('add-children-final', createParentPayload(20000));
34+
const payloadWithRemoval = structuredClone(initialChildrenPayload);
35+
payloadWithRemoval.data.relationships.children.data.splice(0, 19000);
36+
payloadWithRemoval.included.splice(0, 19000);
37+
write('add-children-with-removal', payloadWithRemoval);
38+
3939
write('destroy', createParentPayload(500, 50));
4040
write('relationship-materialization-simple', createCarsPayload(10000));
4141
write('relationship-materialization-complex', createParentRecords(200, 10, 20));

tests/performance/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"scripts": {
1818
"build": "vite build",
1919
"start": "bun ./server/index.ts",
20-
"lint": "eslint . --quiet --cache --cache-strategy=content"
20+
"lint": "eslint . --quiet --cache --cache-strategy=content",
21+
"fixtures": "bun run ./fixtures/index.js"
2122
},
2223
"devDependencies": {
2324
"@babel/core": "^7.26.9",

0 commit comments

Comments
 (0)