@esportsplus/reactivity 0.36.7 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bench/cellx.bench.ts +4 -4
- package/bench/dynamic.bench.ts +10 -9
- package/bench/kairo.bench.ts +28 -33
- package/bench/molbench.bench.ts +4 -4
- package/bench/reactive/array.bench.ts +163 -163
- package/bench/reactive/reactive-object.bench.ts +47 -45
- package/bench/system.bench.ts +263 -263
- package/build/compiler/array.js +68 -73
- package/build/compiler/bindings.d.ts +19 -0
- package/build/compiler/bindings.js +65 -0
- package/build/compiler/index.js +15 -6
- package/build/compiler/object.js +10 -6
- package/build/compiler/primitives.js +137 -138
- package/build/compiler/types.d.ts +7 -2
- package/build/constants.d.ts +1 -1
- package/build/constants.js +4 -4
- package/build/reactive/array.js +19 -12
- package/build/system.js +1 -1
- package/package.json +2 -2
- package/pnpm-workspace.yaml +2 -4
- package/src/compiler/array.ts +86 -89
- package/src/compiler/bindings.ts +100 -0
- package/src/compiler/index.ts +22 -9
- package/src/compiler/object.ts +12 -7
- package/src/compiler/primitives.ts +190 -187
- package/src/compiler/types.ts +7 -2
- package/src/constants.ts +5 -5
- package/src/reactive/array.ts +27 -14
- package/src/system.ts +3 -1
- package/test/async-iterable.test.ts +42 -0
- package/test/compiler/compiler.test.ts +115 -45
- package/test/reactive/array.test.ts +54 -14
- package/vitest.config.ts +2 -2
package/bench/cellx.bench.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { test } from 'vitest';
|
|
2
2
|
import { assert, framework, ReactiveComputed } from './lib/reactive-adapter';
|
|
3
3
|
|
|
4
4
|
|
|
@@ -54,8 +54,8 @@ function cellx(layers: number, before: readonly number[], after: readonly number
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
bench('cellx1000', async () => {
|
|
57
|
+
test('cellx', async ({ bench }) => {
|
|
58
|
+
await bench('cellx1000', async () => {
|
|
59
59
|
await framework.withBuild(() => cellx(1000, [-3, -6, -2, 2], [-2, -4, 2, 3]));
|
|
60
|
-
});
|
|
60
|
+
}).run();
|
|
61
61
|
});
|
package/bench/dynamic.bench.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { test } from 'vitest';
|
|
2
2
|
import { assert, framework, ReactiveComputed } from './lib/reactive-adapter';
|
|
3
3
|
|
|
4
4
|
|
|
@@ -89,15 +89,16 @@ function movingBranchPoint() {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
test('dynamic graphs', async ({ bench }) => {
|
|
93
93
|
let branchRun = framework.withBuild(movingBranchPoint),
|
|
94
94
|
swapRun = framework.withBuild(dependencySwap);
|
|
95
95
|
|
|
96
|
-
bench(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
await bench.compare(
|
|
97
|
+
bench('dependency set swap (20 computeds x 10 deps)', async () => {
|
|
98
|
+
await swapRun();
|
|
99
|
+
}),
|
|
100
|
+
bench('moving branch point (30-deep chain re-link)', async () => {
|
|
101
|
+
await branchRun();
|
|
102
|
+
})
|
|
103
|
+
);
|
|
103
104
|
});
|
package/bench/kairo.bench.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { test } from 'vitest';
|
|
2
2
|
import { assert, framework, ReactiveComputed } from './lib/reactive-adapter';
|
|
3
3
|
|
|
4
4
|
|
|
@@ -324,7 +324,7 @@ function unstable() {
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
|
|
327
|
-
|
|
327
|
+
test('kairo', async ({ bench }) => {
|
|
328
328
|
let avoidableRun = framework.withBuild(avoidablePropagation),
|
|
329
329
|
broadRun = framework.withBuild(broadPropagation),
|
|
330
330
|
deepRun = framework.withBuild(deepPropagation),
|
|
@@ -334,35 +334,30 @@ describe('kairo', () => {
|
|
|
334
334
|
triangleRun = framework.withBuild(triangle),
|
|
335
335
|
unstableRun = framework.withBuild(unstable);
|
|
336
336
|
|
|
337
|
-
bench(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
bench('unstable', async () => {
|
|
366
|
-
await unstableRun();
|
|
367
|
-
});
|
|
337
|
+
await bench.compare(
|
|
338
|
+
bench('avoidablePropagation', async () => {
|
|
339
|
+
await avoidableRun();
|
|
340
|
+
}),
|
|
341
|
+
bench('broad', async () => {
|
|
342
|
+
await broadRun();
|
|
343
|
+
}),
|
|
344
|
+
bench('deep', async () => {
|
|
345
|
+
await deepRun();
|
|
346
|
+
}),
|
|
347
|
+
bench('diamond', async () => {
|
|
348
|
+
await diamondRun();
|
|
349
|
+
}),
|
|
350
|
+
bench('mux', async () => {
|
|
351
|
+
await muxRun();
|
|
352
|
+
}),
|
|
353
|
+
bench('repeatedObservers', async () => {
|
|
354
|
+
await repeatedRun();
|
|
355
|
+
}),
|
|
356
|
+
bench('triangle', async () => {
|
|
357
|
+
await triangleRun();
|
|
358
|
+
}),
|
|
359
|
+
bench('unstable', async () => {
|
|
360
|
+
await unstableRun();
|
|
361
|
+
})
|
|
362
|
+
);
|
|
368
363
|
});
|
package/bench/molbench.bench.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { test } from 'vitest';
|
|
2
2
|
import { assert, framework } from './lib/reactive-adapter';
|
|
3
3
|
|
|
4
4
|
|
|
@@ -66,10 +66,10 @@ function mol() {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
test('molBench', async ({ bench }) => {
|
|
70
70
|
let molRun = framework.withBuild(mol);
|
|
71
71
|
|
|
72
|
-
bench('molBench', async () => {
|
|
72
|
+
await bench('molBench', async () => {
|
|
73
73
|
await molRun();
|
|
74
|
-
});
|
|
74
|
+
}).run();
|
|
75
75
|
});
|
|
@@ -1,233 +1,233 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { test } from 'vitest';
|
|
2
2
|
import { ReactiveArray } from '~/reactive/array';
|
|
3
3
|
import { effect } from '~/system';
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
bench(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
test('ReactiveArray creation', async ({ bench }) => {
|
|
7
|
+
await bench.compare(
|
|
8
|
+
bench('create empty', () => {
|
|
9
|
+
new ReactiveArray<number>();
|
|
10
|
+
}),
|
|
11
|
+
bench('create with 10 items', () => {
|
|
12
|
+
new ReactiveArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
13
|
+
}),
|
|
14
|
+
bench('create with 100 items', () => {
|
|
15
|
+
let items = [];
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < 100; i++) {
|
|
18
|
+
items.push(i);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
new ReactiveArray(items);
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
bench(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
arr.push(1);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
bench('push 10 items (single call)', () => {
|
|
35
|
-
let arr = new ReactiveArray<number>();
|
|
36
|
-
|
|
37
|
-
arr.push(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
|
38
|
-
});
|
|
27
|
+
test('ReactiveArray push', async ({ bench }) => {
|
|
28
|
+
await bench.compare(
|
|
29
|
+
bench('push 1 item', () => {
|
|
30
|
+
let arr = new ReactiveArray<number>();
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
arr.push(1);
|
|
33
|
+
}),
|
|
34
|
+
bench('push 10 items (single call)', () => {
|
|
35
|
+
let arr = new ReactiveArray<number>();
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
arr.push(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
|
38
|
+
}),
|
|
39
|
+
bench('push 10 items (10 calls)', () => {
|
|
40
|
+
let arr = new ReactiveArray<number>();
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
for (let i = 0; i < 10; i++) {
|
|
43
|
+
arr.push(i);
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
bench('push with listener', () => {
|
|
47
|
+
let arr = new ReactiveArray<number>();
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
arr.on('push', () => {});
|
|
50
|
+
arr.push(1);
|
|
51
|
+
})
|
|
52
|
+
);
|
|
54
53
|
});
|
|
55
54
|
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
bench('pop', () => {
|
|
56
|
+
test('ReactiveArray pop', async ({ bench }) => {
|
|
57
|
+
await bench('pop', () => {
|
|
59
58
|
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
60
59
|
|
|
61
60
|
arr.pop();
|
|
62
|
-
});
|
|
61
|
+
}).run();
|
|
63
62
|
});
|
|
64
63
|
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
bench(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
arr.splice(2, 1);
|
|
71
|
-
});
|
|
65
|
+
test('ReactiveArray splice', async ({ bench }) => {
|
|
66
|
+
await bench.compare(
|
|
67
|
+
bench('splice remove 1', () => {
|
|
68
|
+
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
arr.splice(2, 1);
|
|
71
|
+
}),
|
|
72
|
+
bench('splice insert 1', () => {
|
|
73
|
+
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
arr.splice(2, 0, 99);
|
|
76
|
+
}),
|
|
77
|
+
bench('splice replace 1', () => {
|
|
78
|
+
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
arr.splice(2, 1, 99);
|
|
83
|
-
});
|
|
80
|
+
arr.splice(2, 1, 99);
|
|
81
|
+
})
|
|
82
|
+
);
|
|
84
83
|
});
|
|
85
84
|
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
bench(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
arr.sort((a, b) => a - b);
|
|
92
|
-
});
|
|
86
|
+
test('ReactiveArray sort', async ({ bench }) => {
|
|
87
|
+
await bench.compare(
|
|
88
|
+
bench('sort 10 items', () => {
|
|
89
|
+
let arr = new ReactiveArray([5, 3, 8, 1, 9, 2, 7, 4, 6, 10]);
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
arr.sort((a, b) => a - b);
|
|
92
|
+
}),
|
|
93
|
+
bench('sort 100 items', () => {
|
|
94
|
+
let items = [];
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
for (let i = 100; i > 0; i--) {
|
|
97
|
+
items.push(i);
|
|
98
|
+
}
|
|
100
99
|
|
|
101
|
-
|
|
100
|
+
let arr = new ReactiveArray(items);
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
arr.sort((a, b) => a - b);
|
|
103
|
+
}),
|
|
104
|
+
bench('sort 1000 items', () => {
|
|
105
|
+
let items = [];
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
for (let i = 1000; i > 0; i--) {
|
|
108
|
+
items.push(i);
|
|
109
|
+
}
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
items.push(i);
|
|
111
|
-
}
|
|
111
|
+
let arr = new ReactiveArray(items);
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
113
|
+
arr.sort((a, b) => a - b);
|
|
114
|
+
})
|
|
115
|
+
);
|
|
117
116
|
});
|
|
118
117
|
|
|
119
118
|
|
|
120
|
-
|
|
121
|
-
bench(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
arr.$set(2, 99);
|
|
125
|
-
});
|
|
119
|
+
test('ReactiveArray $set', async ({ bench }) => {
|
|
120
|
+
await bench.compare(
|
|
121
|
+
bench('$set', () => {
|
|
122
|
+
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
126
123
|
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
arr.$set(2, 99);
|
|
125
|
+
}),
|
|
126
|
+
bench('$set same value (no-op)', () => {
|
|
127
|
+
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
arr.$set(2, 3);
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
bench(
|
|
137
|
-
|
|
135
|
+
test('ReactiveArray events', async ({ bench }) => {
|
|
136
|
+
await bench.compare(
|
|
137
|
+
bench('dispatch to 1 listener', () => {
|
|
138
|
+
let arr = new ReactiveArray<number>();
|
|
138
139
|
|
|
139
|
-
arr.on('push', () => {});
|
|
140
|
-
arr.push(1);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
bench('dispatch to 10 listeners', () => {
|
|
144
|
-
let arr = new ReactiveArray<number>();
|
|
145
|
-
|
|
146
|
-
for (let i = 0; i < 10; i++) {
|
|
147
140
|
arr.on('push', () => {});
|
|
148
|
-
|
|
141
|
+
arr.push(1);
|
|
142
|
+
}),
|
|
143
|
+
bench('dispatch to 10 listeners', () => {
|
|
144
|
+
let arr = new ReactiveArray<number>();
|
|
149
145
|
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
for (let i = 0; i < 10; i++) {
|
|
147
|
+
arr.on('push', () => {});
|
|
148
|
+
}
|
|
152
149
|
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
arr.push(1);
|
|
151
|
+
}),
|
|
152
|
+
bench('on + once interleaved', () => {
|
|
153
|
+
let arr = new ReactiveArray<number>();
|
|
155
154
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
arr.on('push', () => {});
|
|
156
|
+
arr.once('push', () => {});
|
|
157
|
+
arr.on('push', () => {});
|
|
158
|
+
arr.push(1);
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
bench(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
for (let i = 0; i < 100; i++) {
|
|
169
|
-
items.push(i);
|
|
170
|
-
}
|
|
164
|
+
test('ReactiveArray dispose/clear', async ({ bench }) => {
|
|
165
|
+
await bench.compare(
|
|
166
|
+
bench('dispose with 100 items', () => {
|
|
167
|
+
let items = [];
|
|
171
168
|
|
|
172
|
-
|
|
169
|
+
for (let i = 0; i < 100; i++) {
|
|
170
|
+
items.push(i);
|
|
171
|
+
}
|
|
173
172
|
|
|
174
|
-
|
|
175
|
-
});
|
|
173
|
+
let arr = new ReactiveArray(items);
|
|
176
174
|
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
arr.dispose();
|
|
176
|
+
}),
|
|
177
|
+
bench('clear with 100 items', () => {
|
|
178
|
+
let items = [];
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
for (let i = 0; i < 100; i++) {
|
|
181
|
+
items.push(i);
|
|
182
|
+
}
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
let arr = new ReactiveArray(items);
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
arr.clear();
|
|
187
|
+
})
|
|
188
|
+
);
|
|
188
189
|
});
|
|
189
190
|
|
|
190
191
|
|
|
191
|
-
|
|
192
|
-
bench(
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
test('ReactiveArray concat/unshift/shift/reverse', async ({ bench }) => {
|
|
193
|
+
await bench.compare(
|
|
194
|
+
bench('concat 100 items', () => {
|
|
195
|
+
let arr = new ReactiveArray<number>(),
|
|
196
|
+
items = [];
|
|
195
197
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
for (let i = 0; i < 100; i++) {
|
|
199
|
+
items.push(i);
|
|
200
|
+
}
|
|
199
201
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
205
|
-
|
|
206
|
-
arr.unshift(10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
bench('shift', () => {
|
|
210
|
-
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
202
|
+
arr.concat(items);
|
|
203
|
+
}),
|
|
204
|
+
bench('unshift 10 items', () => {
|
|
205
|
+
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
211
206
|
|
|
212
|
-
|
|
213
|
-
|
|
207
|
+
arr.unshift(10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
|
|
208
|
+
}),
|
|
209
|
+
bench('shift', () => {
|
|
210
|
+
let arr = new ReactiveArray([1, 2, 3, 4, 5]);
|
|
214
211
|
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
arr.shift();
|
|
213
|
+
}),
|
|
214
|
+
bench('reverse 100 items', () => {
|
|
215
|
+
let items = [];
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
for (let i = 0; i < 100; i++) {
|
|
218
|
+
items.push(i);
|
|
219
|
+
}
|
|
221
220
|
|
|
222
|
-
|
|
221
|
+
let arr = new ReactiveArray(items);
|
|
223
222
|
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
arr.reverse();
|
|
224
|
+
})
|
|
225
|
+
);
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
bench('read $length in effect', () => {
|
|
229
|
+
test('ReactiveArray reactive length', async ({ bench }) => {
|
|
230
|
+
await bench('read $length in effect', () => {
|
|
231
231
|
let arr = new ReactiveArray([1, 2, 3]);
|
|
232
232
|
|
|
233
233
|
let stop = effect(() => {
|
|
@@ -235,5 +235,5 @@ describe('ReactiveArray reactive length', () => {
|
|
|
235
235
|
});
|
|
236
236
|
|
|
237
237
|
stop();
|
|
238
|
-
});
|
|
238
|
+
}).run();
|
|
239
239
|
});
|
|
@@ -1,59 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { test } from 'vitest';
|
|
2
2
|
import { ReactiveObject } from '~/reactive/object';
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
bench(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
|
|
5
|
+
test('ReactiveObject creation', async ({ bench }) => {
|
|
6
|
+
await bench.compare(
|
|
7
|
+
bench('create with 5 signal properties', () => {
|
|
8
|
+
new ReactiveObject({ a: 1, b: 2, c: 3, d: 4, e: 5 });
|
|
9
|
+
}),
|
|
10
|
+
bench('create with computed properties', () => {
|
|
11
|
+
new ReactiveObject({
|
|
12
|
+
a: 1,
|
|
13
|
+
b: 2,
|
|
14
|
+
sum: () => 0
|
|
15
|
+
});
|
|
16
|
+
}),
|
|
17
|
+
bench('create with async computed property', () => {
|
|
18
|
+
new ReactiveObject({
|
|
19
|
+
value: 1,
|
|
20
|
+
async: () => Promise.resolve(0)
|
|
21
|
+
});
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
bench(
|
|
29
|
-
|
|
27
|
+
test('ReactiveObject read/write', async ({ bench }) => {
|
|
28
|
+
await bench.compare(
|
|
29
|
+
bench('read property (signal-backed)', () => {
|
|
30
|
+
let obj = new ReactiveObject({ a: 1, b: 2, c: 3, d: 4, e: 5 });
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
(obj as any).a;
|
|
33
|
+
}),
|
|
34
|
+
bench('write property (signal-backed)', () => {
|
|
35
|
+
let obj = new ReactiveObject({ a: 1, b: 2, c: 3, d: 4, e: 5 }),
|
|
36
|
+
i = 0;
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
(obj as any).a = ++i;
|
|
39
|
-
});
|
|
38
|
+
(obj as any).a = ++i;
|
|
39
|
+
})
|
|
40
|
+
);
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
bench(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
obj.dispose();
|
|
48
|
-
});
|
|
44
|
+
test('ReactiveObject dispose', async ({ bench }) => {
|
|
45
|
+
await bench.compare(
|
|
46
|
+
bench('dispose with 5 properties', () => {
|
|
47
|
+
let obj = new ReactiveObject({ a: 1, b: 2, c: 3, d: 4, e: 5 });
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
obj.dispose();
|
|
50
|
+
}),
|
|
51
|
+
bench('dispose with arrays + computeds', () => {
|
|
52
|
+
let obj = new ReactiveObject({
|
|
53
|
+
items: [1, 2, 3],
|
|
54
|
+
name: 'test',
|
|
55
|
+
total: () => 0
|
|
56
|
+
});
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
obj.dispose();
|
|
59
|
+
})
|
|
60
|
+
);
|
|
59
61
|
});
|