@adobe/data 0.1.2
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/README.md +310 -0
- package/assembly/index.d.ts +30 -0
- package/assembly/index.js +18 -0
- package/assembly/index.wasm +0 -0
- package/assembly/index.wasm.map +1 -0
- package/assembly-test/assembly.test.d.ts +1 -0
- package/assembly-test/assembly.test.js +29 -0
- package/assembly-test/assembly.test.js.map +1 -0
- package/cache/async-cache.d.ts +15 -0
- package/cache/async-cache.js +23 -0
- package/cache/async-cache.js.map +1 -0
- package/cache/blob-store.d.ts +94 -0
- package/cache/blob-store.js +191 -0
- package/cache/blob-store.js.map +1 -0
- package/cache/blob-store.test.d.ts +1 -0
- package/cache/blob-store.test.js +142 -0
- package/cache/blob-store.test.js.map +1 -0
- package/cache/data-cache.d.ts +38 -0
- package/cache/data-cache.js +96 -0
- package/cache/data-cache.js.map +1 -0
- package/cache/data-cache.test.d.ts +1 -0
- package/cache/data-cache.test.js +50 -0
- package/cache/data-cache.test.js.map +1 -0
- package/cache/expiring-data-cache.d.ts +6 -0
- package/cache/expiring-data-cache.js +49 -0
- package/cache/expiring-data-cache.js.map +1 -0
- package/cache/expiring-data-cache.test.d.ts +1 -0
- package/cache/expiring-data-cache.test.js +62 -0
- package/cache/expiring-data-cache.test.js.map +1 -0
- package/cache/fallback-async-cache.d.ts +7 -0
- package/cache/fallback-async-cache.js +22 -0
- package/cache/fallback-async-cache.js.map +1 -0
- package/cache/functions/bind-functions.d.ts +6 -0
- package/cache/functions/bind-functions.js +33 -0
- package/cache/functions/bind-functions.js.map +1 -0
- package/cache/functions/functions.test.d.ts +1 -0
- package/cache/functions/functions.test.js +79 -0
- package/cache/functions/functions.test.js.map +1 -0
- package/cache/functions/get-cached.d.ts +11 -0
- package/cache/functions/get-cached.js +49 -0
- package/cache/functions/get-cached.js.map +1 -0
- package/cache/functions/get-cached.test.d.ts +1 -0
- package/cache/functions/get-cached.test.js +96 -0
- package/cache/functions/get-cached.test.js.map +1 -0
- package/cache/functions/hashing/blob-to-hash.d.ts +4 -0
- package/cache/functions/hashing/blob-to-hash.js +44 -0
- package/cache/functions/hashing/blob-to-hash.js.map +1 -0
- package/cache/functions/hashing/buffer-to-hash.d.ts +4 -0
- package/cache/functions/hashing/buffer-to-hash.js +33 -0
- package/cache/functions/hashing/buffer-to-hash.js.map +1 -0
- package/cache/functions/hashing/hashing.test.d.ts +1 -0
- package/cache/functions/hashing/hashing.test.js +95 -0
- package/cache/functions/hashing/hashing.test.js.map +1 -0
- package/cache/functions/hashing/index.d.ts +4 -0
- package/cache/functions/hashing/index.js +26 -0
- package/cache/functions/hashing/index.js.map +1 -0
- package/cache/functions/hashing/json-to-hash.d.ts +4 -0
- package/cache/functions/hashing/json-to-hash.js +29 -0
- package/cache/functions/hashing/json-to-hash.js.map +1 -0
- package/cache/functions/hashing/string-to-hash.d.ts +4 -0
- package/cache/functions/hashing/string-to-hash.js +37 -0
- package/cache/functions/hashing/string-to-hash.js.map +1 -0
- package/cache/functions/index.d.ts +5 -0
- package/cache/functions/index.js +29 -0
- package/cache/functions/index.js.map +1 -0
- package/cache/functions/memoize.d.ts +12 -0
- package/cache/functions/memoize.js +48 -0
- package/cache/functions/memoize.js.map +1 -0
- package/cache/functions/omit.d.ts +1 -0
- package/cache/functions/omit.js +29 -0
- package/cache/functions/omit.js.map +1 -0
- package/cache/functions/prevent-parallel-execution.d.ts +7 -0
- package/cache/functions/prevent-parallel-execution.js +25 -0
- package/cache/functions/prevent-parallel-execution.js.map +1 -0
- package/cache/functions/types.d.ts +1 -0
- package/cache/functions/types.js +23 -0
- package/cache/functions/types.js.map +1 -0
- package/cache/get-persistent-cache.d.ts +12 -0
- package/cache/get-persistent-cache.js +23 -0
- package/cache/get-persistent-cache.js.map +1 -0
- package/cache/index.d.ts +3 -0
- package/cache/index.js +25 -0
- package/cache/index.js.map +1 -0
- package/cache/managed-array.d.ts +23 -0
- package/cache/managed-array.js +160 -0
- package/cache/managed-array.js.map +1 -0
- package/cache/managed-async-cache.browser.test.d.ts +1 -0
- package/cache/managed-async-cache.browser.test.js +50 -0
- package/cache/managed-async-cache.browser.test.js.map +1 -0
- package/cache/managed-async-cache.d.ts +4 -0
- package/cache/managed-async-cache.js +45 -0
- package/cache/managed-async-cache.js.map +1 -0
- package/cache/memory-allocator.d.ts +23 -0
- package/cache/memory-allocator.js +94 -0
- package/cache/memory-allocator.js.map +1 -0
- package/cache/memory-async-cache.d.ts +6 -0
- package/cache/memory-async-cache.js +23 -0
- package/cache/memory-async-cache.js.map +1 -0
- package/core/data.d.ts +22 -0
- package/core/data.js +52 -0
- package/core/data.js.map +1 -0
- package/core/data.test.d.ts +1 -0
- package/core/data.test.js +48 -0
- package/core/data.test.js.map +1 -0
- package/core/functions/array-equals.d.ts +1 -0
- package/core/functions/array-equals.js +34 -0
- package/core/functions/array-equals.js.map +1 -0
- package/core/functions/deep-merge.d.ts +31 -0
- package/core/functions/deep-merge.js +51 -0
- package/core/functions/deep-merge.js.map +1 -0
- package/core/functions/deep-merge.test.d.ts +1 -0
- package/core/functions/deep-merge.test.js +94 -0
- package/core/functions/deep-merge.test.js.map +1 -0
- package/core/functions/index.d.ts +4 -0
- package/core/functions/index.js +26 -0
- package/core/functions/index.js.map +1 -0
- package/core/functions/is-async-generator.d.ts +1 -0
- package/core/functions/is-async-generator.js +25 -0
- package/core/functions/is-async-generator.js.map +1 -0
- package/core/functions/is-promise.d.ts +1 -0
- package/core/functions/is-promise.js +26 -0
- package/core/functions/is-promise.js.map +1 -0
- package/core/functions/with-validation.d.ts +5 -0
- package/core/functions/with-validation.js +38 -0
- package/core/functions/with-validation.js.map +1 -0
- package/core/functions/with-validation.test.d.ts +1 -0
- package/core/functions/with-validation.test.js +96 -0
- package/core/functions/with-validation.test.js.map +1 -0
- package/core/index.d.ts +3 -0
- package/core/index.js +25 -0
- package/core/index.js.map +1 -0
- package/core/schema.d.ts +86 -0
- package/core/schema.js +33 -0
- package/core/schema.js.map +1 -0
- package/core/schema.test.d.ts +1 -0
- package/core/schema.test.js +16 -0
- package/core/schema.test.js.map +1 -0
- package/ecs/action-ecs/action-ecs.d.ts +19 -0
- package/ecs/action-ecs/action-ecs.js +203 -0
- package/ecs/action-ecs/action-ecs.js.map +1 -0
- package/ecs/action-ecs/action-ecs.test.d.ts +1 -0
- package/ecs/action-ecs/action-ecs.test.js +362 -0
- package/ecs/action-ecs/action-ecs.test.js.map +1 -0
- package/ecs/action-ecs/action-types.d.ts +106 -0
- package/ecs/action-ecs/action-types.js +19 -0
- package/ecs/action-ecs/action-types.js.map +1 -0
- package/ecs/action-ecs/index.d.ts +2 -0
- package/ecs/action-ecs/index.js +23 -0
- package/ecs/action-ecs/index.js.map +1 -0
- package/ecs/core-ecs/core-ecs-serialization.test.d.ts +1 -0
- package/ecs/core-ecs/core-ecs-serialization.test.js +230 -0
- package/ecs/core-ecs/core-ecs-serialization.test.js.map +1 -0
- package/ecs/core-ecs/core-ecs-types.d.ts +141 -0
- package/ecs/core-ecs/core-ecs-types.js +23 -0
- package/ecs/core-ecs/core-ecs-types.js.map +1 -0
- package/ecs/core-ecs/core-ecs.d.ts +7 -0
- package/ecs/core-ecs/core-ecs.js +492 -0
- package/ecs/core-ecs/core-ecs.js.map +1 -0
- package/ecs/core-ecs/core-ecs.test.d.ts +1 -0
- package/ecs/core-ecs/core-ecs.test.js +404 -0
- package/ecs/core-ecs/core-ecs.test.js.map +1 -0
- package/ecs/core-ecs/index.d.ts +1 -0
- package/ecs/core-ecs/index.js +2 -0
- package/ecs/core-ecs/index.js.map +1 -0
- package/ecs/ecs/ecs-types.d.ts +132 -0
- package/ecs/ecs/ecs-types.js +23 -0
- package/ecs/ecs/ecs-types.js.map +1 -0
- package/ecs/ecs/ecs-where-functions.d.ts +6 -0
- package/ecs/ecs/ecs-where-functions.js +91 -0
- package/ecs/ecs/ecs-where-functions.js.map +1 -0
- package/ecs/ecs/ecs.d.ts +13 -0
- package/ecs/ecs/ecs.js +177 -0
- package/ecs/ecs/ecs.js.map +1 -0
- package/ecs/ecs/ecs.test.d.ts +1 -0
- package/ecs/ecs/ecs.test.js +399 -0
- package/ecs/ecs/ecs.test.js.map +1 -0
- package/ecs/ecs/index.d.ts +3 -0
- package/ecs/ecs/index.js +3 -0
- package/ecs/ecs/index.js.map +1 -0
- package/ecs/index.d.ts +4 -0
- package/ecs/index.js +26 -0
- package/ecs/index.js.map +1 -0
- package/ecs/transaction-ecs/index.d.ts +2 -0
- package/ecs/transaction-ecs/index.js +24 -0
- package/ecs/transaction-ecs/index.js.map +1 -0
- package/ecs/transaction-ecs/transaction-ecs.d.ts +11 -0
- package/ecs/transaction-ecs/transaction-ecs.js +184 -0
- package/ecs/transaction-ecs/transaction-ecs.js.map +1 -0
- package/ecs/transaction-ecs/transaction-ecs.test.d.ts +1 -0
- package/ecs/transaction-ecs/transaction-ecs.test.js +599 -0
- package/ecs/transaction-ecs/transaction-ecs.test.js.map +1 -0
- package/ecs/transaction-ecs/transaction-types.d.ts +135 -0
- package/ecs/transaction-ecs/transaction-types.js +2 -0
- package/ecs/transaction-ecs/transaction-types.js.map +1 -0
- package/ecs/transaction-ecs/transactions.d.ts +5 -0
- package/ecs/transaction-ecs/transactions.js +158 -0
- package/ecs/transaction-ecs/transactions.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +23 -0
- package/index.js.map +1 -0
- package/observe/create-observable-event.d.ts +10 -0
- package/observe/create-observable-event.js +22 -0
- package/observe/create-observable-event.js.map +1 -0
- package/observe/create-observable-state.d.ts +7 -0
- package/observe/create-observable-state.js +27 -0
- package/observe/create-observable-state.js.map +1 -0
- package/observe/create-persisted-state.d.ts +11 -0
- package/observe/create-persisted-state.js +31 -0
- package/observe/create-persisted-state.js.map +1 -0
- package/observe/create-persisted-state.test.d.ts +1 -0
- package/observe/create-persisted-state.test.js +124 -0
- package/observe/create-persisted-state.test.js.map +1 -0
- package/observe/from-array.d.ts +5 -0
- package/observe/from-array.js +30 -0
- package/observe/from-array.js.map +1 -0
- package/observe/from-constant.d.ts +5 -0
- package/observe/from-constant.js +12 -0
- package/observe/from-constant.js.map +1 -0
- package/observe/from-element-id.d.ts +7 -0
- package/observe/from-element-id.js +70 -0
- package/observe/from-element-id.js.map +1 -0
- package/observe/from-element-properties-and-events.d.ts +2 -0
- package/observe/from-element-properties-and-events.js +18 -0
- package/observe/from-element-properties-and-events.js.map +1 -0
- package/observe/from-element-property.d.ts +11 -0
- package/observe/from-element-property.js +60 -0
- package/observe/from-element-property.js.map +1 -0
- package/observe/from-promise-with-error.d.ts +7 -0
- package/observe/from-promise-with-error.js +27 -0
- package/observe/from-promise-with-error.js.map +1 -0
- package/observe/from-promise.d.ts +6 -0
- package/observe/from-promise.js +22 -0
- package/observe/from-promise.js.map +1 -0
- package/observe/from-properties.d.ts +10 -0
- package/observe/from-properties.js +33 -0
- package/observe/from-properties.js.map +1 -0
- package/observe/index.d.ts +27 -0
- package/observe/index.js +49 -0
- package/observe/index.js.map +1 -0
- package/observe/observe.test.d.ts +7 -0
- package/observe/observe.test.js +417 -0
- package/observe/observe.test.js.map +1 -0
- package/observe/to-promise.d.ts +8 -0
- package/observe/to-promise.js +18 -0
- package/observe/to-promise.js.map +1 -0
- package/observe/to-properties.d.ts +11 -0
- package/observe/to-properties.js +9 -0
- package/observe/to-properties.js.map +1 -0
- package/observe/types.d.ts +17 -0
- package/observe/types.js +2 -0
- package/observe/types.js.map +1 -0
- package/observe/with-async-map.d.ts +6 -0
- package/observe/with-async-map.js +12 -0
- package/observe/with-async-map.js.map +1 -0
- package/observe/with-cache.d.ts +6 -0
- package/observe/with-cache.js +33 -0
- package/observe/with-cache.js.map +1 -0
- package/observe/with-copy.d.ts +5 -0
- package/observe/with-copy.js +10 -0
- package/observe/with-copy.js.map +1 -0
- package/observe/with-deduplicate-data.d.ts +7 -0
- package/observe/with-deduplicate-data.js +18 -0
- package/observe/with-deduplicate-data.js.map +1 -0
- package/observe/with-deduplicate.d.ts +6 -0
- package/observe/with-deduplicate.js +19 -0
- package/observe/with-deduplicate.js.map +1 -0
- package/observe/with-default.d.ts +6 -0
- package/observe/with-default.js +21 -0
- package/observe/with-default.js.map +1 -0
- package/observe/with-map-data.d.ts +7 -0
- package/observe/with-map-data.js +32 -0
- package/observe/with-map-data.js.map +1 -0
- package/observe/with-map.d.ts +5 -0
- package/observe/with-map.js +11 -0
- package/observe/with-map.js.map +1 -0
- package/observe/with-optional.d.ts +5 -0
- package/observe/with-optional.js +20 -0
- package/observe/with-optional.js.map +1 -0
- package/observe/with-unwrap.d.ts +5 -0
- package/observe/with-unwrap.js +26 -0
- package/observe/with-unwrap.js.map +1 -0
- package/package.json +105 -0
- package/perftest/ecs-perf.d.ts +49 -0
- package/perftest/ecs-perf.js +230 -0
- package/perftest/ecs-perf.js.map +1 -0
- package/perftest/helper-functions.d.ts +1 -0
- package/perftest/helper-functions.js +31 -0
- package/perftest/helper-functions.js.map +1 -0
- package/perftest/horizon-perf.d.ts +22 -0
- package/perftest/horizon-perf.js +126 -0
- package/perftest/horizon-perf.js.map +1 -0
- package/perftest/index.d.ts +1 -0
- package/perftest/index.js +35 -0
- package/perftest/index.js.map +1 -0
- package/perftest/perf-test.d.ts +18 -0
- package/perftest/perf-test.js +124 -0
- package/perftest/perf-test.js.map +1 -0
- package/perftest/vanilla-perf.d.ts +38 -0
- package/perftest/vanilla-perf.js +128 -0
- package/perftest/vanilla-perf.js.map +1 -0
- package/schemas/index.d.ts +1 -0
- package/schemas/index.js +23 -0
- package/schemas/index.js.map +1 -0
- package/schemas/schemas.d.ts +45 -0
- package/schemas/schemas.js +39 -0
- package/schemas/schemas.js.map +1 -0
- package/service/add-observable-actions.d.ts +29 -0
- package/service/add-observable-actions.js +108 -0
- package/service/add-observable-actions.js.map +1 -0
- package/service/index.d.ts +4 -0
- package/service/index.js +26 -0
- package/service/index.js.map +1 -0
- package/service/progressive-result.d.ts +96 -0
- package/service/progressive-result.js +99 -0
- package/service/progressive-result.js.map +1 -0
- package/service/sequential-action.d.ts +18 -0
- package/service/sequential-action.js +45 -0
- package/service/sequential-action.js.map +1 -0
- package/service/service.d.ts +4 -0
- package/service/service.js +26 -0
- package/service/service.js.map +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +23 -0
- package/types/index.js.map +1 -0
- package/types/types.d.ts +61 -0
- package/types/types.js +27 -0
- package/types/types.js.map +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const horizon: {
|
|
2
|
+
create: {
|
|
3
|
+
setup: (n: number) => Promise<void>;
|
|
4
|
+
run: () => void;
|
|
5
|
+
cleanup: () => Promise<void>;
|
|
6
|
+
type: "create";
|
|
7
|
+
};
|
|
8
|
+
move_best: {
|
|
9
|
+
setup: (n: number) => Promise<void>;
|
|
10
|
+
run: () => void;
|
|
11
|
+
cleanup: () => Promise<void>;
|
|
12
|
+
getVisibleEnabledPositions: () => number[];
|
|
13
|
+
type: "move";
|
|
14
|
+
};
|
|
15
|
+
move_worst: {
|
|
16
|
+
setup: (n: number) => Promise<void>;
|
|
17
|
+
run: () => void;
|
|
18
|
+
cleanup: () => Promise<void>;
|
|
19
|
+
getVisibleEnabledPositions: () => number[];
|
|
20
|
+
type: "move";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*MIT License
|
|
2
|
+
|
|
3
|
+
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.*/
|
|
22
|
+
import { shuffleArray } from "./helper-functions.js";
|
|
23
|
+
function uuidv4() {
|
|
24
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
25
|
+
const r = (Math.random() * 16) | 0;
|
|
26
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
27
|
+
return v.toString(16);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// uuid-imports.d.ts
|
|
31
|
+
async function createParticles(count) {
|
|
32
|
+
const particlesIds = [];
|
|
33
|
+
const components = new Map();
|
|
34
|
+
const setComponent = (name, key, value) => {
|
|
35
|
+
let component = components.get(name);
|
|
36
|
+
if (!component) {
|
|
37
|
+
component = new Map();
|
|
38
|
+
components.set(name, component);
|
|
39
|
+
}
|
|
40
|
+
component.set(key, value);
|
|
41
|
+
};
|
|
42
|
+
const getComponent = (name, key) => {
|
|
43
|
+
const component = components.get(name);
|
|
44
|
+
if (!component) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return component.get(key);
|
|
48
|
+
};
|
|
49
|
+
const particles = [];
|
|
50
|
+
for (let i = 0; i < count; i++) {
|
|
51
|
+
const entity = uuidv4();
|
|
52
|
+
particlesIds.push(entity);
|
|
53
|
+
setComponent(entity, "color", { value: 0xff00ff });
|
|
54
|
+
setComponent(entity, "mass", { value: 10 });
|
|
55
|
+
setComponent(entity, "position", { x: i + 1, y: i + 1, z: i + 1 });
|
|
56
|
+
setComponent(entity, "velocity", { x: -i, y: -i, z: -i });
|
|
57
|
+
if ((i >> 0) % 2 === 0) {
|
|
58
|
+
setComponent(entity, "visible", true);
|
|
59
|
+
}
|
|
60
|
+
if ((i >> 1) % 2 === 0) {
|
|
61
|
+
setComponent(entity, "enabled", true);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const enabledVisibleParticles = particlesIds.filter((id, i) => {
|
|
65
|
+
return getComponent(id, "enabled") && getComponent(id, "visible");
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
particles,
|
|
69
|
+
components,
|
|
70
|
+
setComponent,
|
|
71
|
+
getComponent,
|
|
72
|
+
enabledVisibleParticles,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const create = (() => {
|
|
76
|
+
let count = 0;
|
|
77
|
+
const setup = async (n) => {
|
|
78
|
+
count = n;
|
|
79
|
+
};
|
|
80
|
+
const run = () => {
|
|
81
|
+
createParticles(count);
|
|
82
|
+
};
|
|
83
|
+
const cleanup = async () => { };
|
|
84
|
+
return { setup, run: run, cleanup, type: "create" };
|
|
85
|
+
})();
|
|
86
|
+
function createMoveParticlesPerformanceTest(options) {
|
|
87
|
+
let ecs;
|
|
88
|
+
const setup = async (n) => {
|
|
89
|
+
ecs = await createParticles(n);
|
|
90
|
+
if (options.shuffle) {
|
|
91
|
+
shuffleArray(ecs.particles);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const run = () => {
|
|
95
|
+
for (let i = 0; i < ecs.enabledVisibleParticles.length; i++) {
|
|
96
|
+
const p = ecs.enabledVisibleParticles[i];
|
|
97
|
+
const position = ecs.getComponent(p, "position");
|
|
98
|
+
const velocity = ecs.getComponent(p, "velocity");
|
|
99
|
+
const newPosition = {
|
|
100
|
+
x: position.x + velocity.x,
|
|
101
|
+
y: position.y + velocity.y,
|
|
102
|
+
z: position.z + velocity.z,
|
|
103
|
+
};
|
|
104
|
+
ecs.setComponent(p, "position", newPosition);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const getVisibleEnabledPositions = () => {
|
|
108
|
+
const values = [];
|
|
109
|
+
for (let i = 0; i < ecs.enabledVisibleParticles.length; i++) {
|
|
110
|
+
const p = ecs.enabledVisibleParticles[i];
|
|
111
|
+
const position = ecs.getComponent(p, "position");
|
|
112
|
+
values.push(position.x, position.y, position.z);
|
|
113
|
+
}
|
|
114
|
+
return values;
|
|
115
|
+
};
|
|
116
|
+
const cleanup = async () => { };
|
|
117
|
+
return { setup, run: run, cleanup, getVisibleEnabledPositions, type: "move" };
|
|
118
|
+
}
|
|
119
|
+
const move_best = createMoveParticlesPerformanceTest({ shuffle: false });
|
|
120
|
+
const move_worst = createMoveParticlesPerformanceTest({ shuffle: true });
|
|
121
|
+
export const horizon = {
|
|
122
|
+
create,
|
|
123
|
+
move_best,
|
|
124
|
+
move_worst,
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=horizon-perf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"horizon-perf.js","sourceRoot":"","sources":["../../src/perftest/horizon-perf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AACX,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,SAAS,MAAM;IACb,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC;QACxE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,G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tC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5D,MAAM,CAAC,GAAG,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;YACzC,MAAM,QAAQ,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;YACjD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAA;IACD,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC;IAC/B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,0BAA0B,EAAE,IAAI,EAAE,MAAM,EAA4B,CAAC;AAC1G,CAAC;AAED,MAAM,SAAS,GAAG,kCAAkC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACzE,MAAM,UAAU,GAAG,kCAAkC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAEzE,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,MAAM;IACN,SAAS;IACT,UAAU;CACX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function run(): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*MIT License
|
|
2
|
+
|
|
3
|
+
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.*/
|
|
22
|
+
import * as vanilla_tests from "./vanilla-perf.js";
|
|
23
|
+
import * as ecs_tests from "./ecs-perf.js";
|
|
24
|
+
import { runTests } from "./perf-test.js";
|
|
25
|
+
export function run() {
|
|
26
|
+
runTests({
|
|
27
|
+
...ecs_tests,
|
|
28
|
+
...vanilla_tests,
|
|
29
|
+
// ...horizon_tests,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (typeof globalThis.process === "object" && import.meta.url === `file://${process?.argv[1]}`) {
|
|
33
|
+
run();
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/perftest/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AACX,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,SAAS,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,UAAU,GAAG;IACjB,QAAQ,CAAC;QACP,GAAG,SAAS;QACZ,GAAG,aAAa;QAChB,oBAAoB;KACrB,CAAC,CAAC;AACL,CAAC;AAED,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC/F,GAAG,EAAE,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Performance {
|
|
3
|
+
measureUserAgentSpecificMemory?: () => {
|
|
4
|
+
bytes: number;
|
|
5
|
+
};
|
|
6
|
+
memory?: {
|
|
7
|
+
usedJSHeapSize: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export interface PerformanceTest {
|
|
12
|
+
setup: (n: number) => Promise<void>;
|
|
13
|
+
run: () => any;
|
|
14
|
+
getVisibleEnabledPositions?: () => number[];
|
|
15
|
+
type: "create" | "move";
|
|
16
|
+
cleanup: () => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare function runTests(testSuites: Record<string, Record<string, PerformanceTest>>): Promise<void>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const typeToFlops = {
|
|
2
|
+
create: 10,
|
|
3
|
+
move: 3 / 4,
|
|
4
|
+
};
|
|
5
|
+
function isPerformanceTest(obj) {
|
|
6
|
+
return (typeof obj.setup === "function" &&
|
|
7
|
+
typeof obj.run === "function" &&
|
|
8
|
+
typeof obj.cleanup === "function");
|
|
9
|
+
}
|
|
10
|
+
function getMemory() {
|
|
11
|
+
// if in the browser, try to get browser memory usage
|
|
12
|
+
if (typeof window !== "undefined") {
|
|
13
|
+
return performance.memory?.usedJSHeapSize ?? 0;
|
|
14
|
+
}
|
|
15
|
+
return performance.measureUserAgentSpecificMemory?.().bytes ?? 0;
|
|
16
|
+
}
|
|
17
|
+
function getTime() {
|
|
18
|
+
return performance.now();
|
|
19
|
+
}
|
|
20
|
+
function garbageCollect() {
|
|
21
|
+
if (typeof globalThis.gc === "function") {
|
|
22
|
+
globalThis.gc();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function runTests(testSuites) {
|
|
26
|
+
console.log("Starting Tests:");
|
|
27
|
+
const allResults = {};
|
|
28
|
+
const display = (name) => name.replace(/_/g, " ");
|
|
29
|
+
for (const [suite, tests] of Object.entries(testSuites)) {
|
|
30
|
+
console.log(`- ${display(suite)}...`);
|
|
31
|
+
const suiteResults = (allResults[suite] = {});
|
|
32
|
+
for (const [name, test] of Object.entries(tests)) {
|
|
33
|
+
console.log(` - ${display(name)}...`);
|
|
34
|
+
const testResults = [];
|
|
35
|
+
suiteResults[name] = testResults;
|
|
36
|
+
if (test.getVisibleEnabledPositions) {
|
|
37
|
+
if (test.type === "create") {
|
|
38
|
+
throw new Error("Cannot have getVisibleEnabledPositions with create test");
|
|
39
|
+
}
|
|
40
|
+
// we will run a small n sample of this to verify it works correctly.
|
|
41
|
+
const sample_n = 17;
|
|
42
|
+
await test.setup(sample_n);
|
|
43
|
+
const initialPositions = test.getVisibleEnabledPositions();
|
|
44
|
+
const expectedInitialPositions = [1, 1, 1, 5, 5, 5, 9, 9, 9, 13, 13, 13, 17, 17, 17];
|
|
45
|
+
if (JSON.stringify(initialPositions) !== JSON.stringify(expectedInitialPositions)) {
|
|
46
|
+
console.log(` Error: invalid initial positions: ${initialPositions}, expected. ${expectedInitialPositions}`);
|
|
47
|
+
}
|
|
48
|
+
// console.log(JSON.stringify(initialPositions));
|
|
49
|
+
// run the test once to add to visible, enabled particle positions.
|
|
50
|
+
test.run();
|
|
51
|
+
const finalPositions = test.getVisibleEnabledPositions();
|
|
52
|
+
const expectedFinalPositions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
|
|
53
|
+
if (JSON.stringify(finalPositions) !== JSON.stringify(expectedFinalPositions)) {
|
|
54
|
+
console.log(` Error: invalid final positions: ${finalPositions}, expected. ${expectedFinalPositions}`);
|
|
55
|
+
}
|
|
56
|
+
// console.log(JSON.stringify(finalPositions));
|
|
57
|
+
}
|
|
58
|
+
const n = test.getVisibleEnabledPositions ? 100000 : 100000;
|
|
59
|
+
await test.setup(n);
|
|
60
|
+
garbageCollect();
|
|
61
|
+
const baselineMemory = getMemory();
|
|
62
|
+
const timeStart = getTime();
|
|
63
|
+
// only run for 1 second
|
|
64
|
+
while (getTime() - timeStart < 100) {
|
|
65
|
+
const result = runOnce(test.run, test);
|
|
66
|
+
result.memoryKb -= baselineMemory;
|
|
67
|
+
testResults.push({ ...result, flops: n * typeToFlops[test.type] });
|
|
68
|
+
}
|
|
69
|
+
await test.cleanup();
|
|
70
|
+
garbageCollect();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// console.log(allResults);
|
|
74
|
+
// console log some meaningful and readable results for each test that include the min, max and average times
|
|
75
|
+
if (typeof console.table === "function") {
|
|
76
|
+
// Let's use the console table function to layout some nice results that the best results in time and memory
|
|
77
|
+
// are easy to see.
|
|
78
|
+
const tableValues = {};
|
|
79
|
+
for (const [suite, suiteResults] of Object.entries(allResults)) {
|
|
80
|
+
for (const [name, testResults] of Object.entries(suiteResults)) {
|
|
81
|
+
const memoryKb = testResults.map((r) => r.memoryKb / (1024 * 1024));
|
|
82
|
+
const timeMs = testResults.map((r) => r.timeMs);
|
|
83
|
+
const fastestResult = testResults.reduce((a, b) => (a.timeMs < b.timeMs ? a : b));
|
|
84
|
+
const fastestFlopsPerSecond = (fastestResult.flops * 1000) / (fastestResult.timeMs);
|
|
85
|
+
const totalTime = timeMs.reduce((a, b) => a + b, 0);
|
|
86
|
+
const totalFlops = testResults.reduce((a, b) => a + b.flops, 0);
|
|
87
|
+
const averageFlopsPerSecond = (totalFlops * 1000) / totalTime;
|
|
88
|
+
tableValues[`${display(suite)}:${display(name)}`] = {
|
|
89
|
+
Passes: memoryKb.length,
|
|
90
|
+
// 'Mem Min (Mb)': Math.min(...memoryKb).toFixed(2),
|
|
91
|
+
// 'Mem Max (Mb)': Math.max(...memoryKb).toFixed(2),
|
|
92
|
+
// "Mem Avg (Mb)": (
|
|
93
|
+
// memoryKb.reduce((a, b) => a + b, 0) / memoryKb.length
|
|
94
|
+
// ).toFixed(2),
|
|
95
|
+
"Time Min (ms)": Math.min(...timeMs).toFixed(2),
|
|
96
|
+
// 'Time Max (ms)': Math.max(...timeMs).toFixed(2),
|
|
97
|
+
"Time Avg (ms)": (timeMs.reduce((a, b) => a + b, 0) / timeMs.length).toFixed(2),
|
|
98
|
+
"Fastest MFlops": Math.round(fastestFlopsPerSecond / 1000000),
|
|
99
|
+
"Average MFlops": Math.round(averageFlopsPerSecond / 1000000),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
console.table(tableValues);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
for (const [suite, suiteResults] of Object.entries(allResults)) {
|
|
107
|
+
for (const [name, testResults] of Object.entries(suiteResults)) {
|
|
108
|
+
const memoryKb = testResults.map((r) => r.memoryKb);
|
|
109
|
+
const timeMs = testResults.map((r) => r.timeMs);
|
|
110
|
+
console.log(`${name}: ${Math.min(...memoryKb)}kb - ${Math.max(...memoryKb)}kb - ${Math.round(memoryKb.reduce((a, b) => a + b, 0) / memoryKb.length)}kb`);
|
|
111
|
+
console.log(`${name}: ${Math.round(Math.min(...timeMs))}ms - ${Math.round(Math.max(...timeMs))}ms - ${Math.round(timeMs.reduce((a, b) => a + b, 0) / timeMs.length)}ms`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function runOnce(fn, test) {
|
|
117
|
+
const start = getTime();
|
|
118
|
+
const result = fn();
|
|
119
|
+
const end = getTime();
|
|
120
|
+
const after = getMemory();
|
|
121
|
+
const timeMs = end - start;
|
|
122
|
+
return { memoryKb: after, timeMs, result };
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=perf-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perf-test.js","sourceRoot":"","sources":["../../src/perftest/perf-test.ts"],"names":[],"mappings":"AA2CA,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,CAAC,GAAG,CAAC;CAC+C,CAAC;AAE7D,SAAS,iBAAiB,CAAC,GAAQ;IACjC,OAAO,CACL,OAAO,GAAG,CAAC,KAAK,KAAK,UAAU;QAC/B,OAAO,GAAG,CAAC,GAAG,KAAK,UAAU;QAC7B,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CAClC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS;IAChB,sDAAsD;IACtD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,WAAW,CAAC,MAAM,EAAE,cAAc,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,WAAW,CAAC,8BAA8B,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,OAAO;IACd,OAAO,WAAW,CAAC,GAAG,EAAE,CAAC;AAC3B,CAAC;AAED,SAAS,cAAc;IACrB,IAAI,OAAO,UAAU,CAAC,EAAE,KAAK,UAAU,EAAE,CAAC;QACxC,UAAU,CAAC,EAAE,EAAE,CAAC;IAClB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,UAA2D;IAE3D,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/B,MAAM,UAAU,GAAkD,EAAE,CAAC;IACrE,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1D,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAA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
|
3
|
+
setup: (n: number) => Promise<void>;
|
|
4
|
+
run: () => void;
|
|
5
|
+
cleanup: () => Promise<void>;
|
|
6
|
+
type: "create";
|
|
7
|
+
};
|
|
8
|
+
move_best: {
|
|
9
|
+
setup: (n: number) => Promise<void>;
|
|
10
|
+
run: () => void;
|
|
11
|
+
cleanup: () => Promise<void>;
|
|
12
|
+
getVisibleEnabledPositions: (() => number[]) | undefined;
|
|
13
|
+
type: "move";
|
|
14
|
+
};
|
|
15
|
+
move_worst: {
|
|
16
|
+
setup: (n: number) => Promise<void>;
|
|
17
|
+
run: () => void;
|
|
18
|
+
cleanup: () => Promise<void>;
|
|
19
|
+
getVisibleEnabledPositions: (() => number[]) | undefined;
|
|
20
|
+
type: "move";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const immutable_js: {
|
|
24
|
+
move_best: {
|
|
25
|
+
setup: (n: number) => Promise<void>;
|
|
26
|
+
run: () => void;
|
|
27
|
+
cleanup: () => Promise<void>;
|
|
28
|
+
getVisibleEnabledPositions: (() => number[]) | undefined;
|
|
29
|
+
type: "move";
|
|
30
|
+
};
|
|
31
|
+
move_worst: {
|
|
32
|
+
setup: (n: number) => Promise<void>;
|
|
33
|
+
run: () => void;
|
|
34
|
+
cleanup: () => Promise<void>;
|
|
35
|
+
getVisibleEnabledPositions: (() => number[]) | undefined;
|
|
36
|
+
type: "move";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*MIT License
|
|
2
|
+
|
|
3
|
+
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.*/
|
|
22
|
+
import { shuffleArray } from "./helper-functions.js";
|
|
23
|
+
function createParticlesJS(n) {
|
|
24
|
+
const particles = [];
|
|
25
|
+
for (let i = 0; i < n; i++) {
|
|
26
|
+
const particle = {
|
|
27
|
+
color: 0xff00ff,
|
|
28
|
+
mass: 10,
|
|
29
|
+
positionX: i + 1,
|
|
30
|
+
positionY: i + 1,
|
|
31
|
+
positionZ: i + 1,
|
|
32
|
+
velocityX: -i,
|
|
33
|
+
velocityY: -i,
|
|
34
|
+
velocityZ: -i,
|
|
35
|
+
};
|
|
36
|
+
if ((i >> 0) % 2 === 0) {
|
|
37
|
+
particle.visible = true;
|
|
38
|
+
}
|
|
39
|
+
if ((i >> 1) % 2 === 0) {
|
|
40
|
+
particle.enabled = true;
|
|
41
|
+
}
|
|
42
|
+
particles.push(particle);
|
|
43
|
+
}
|
|
44
|
+
return particles;
|
|
45
|
+
}
|
|
46
|
+
const create = (() => {
|
|
47
|
+
let count = 0;
|
|
48
|
+
const setup = async (n) => {
|
|
49
|
+
count = n;
|
|
50
|
+
};
|
|
51
|
+
const run = () => {
|
|
52
|
+
createParticlesJS(count);
|
|
53
|
+
};
|
|
54
|
+
const cleanup = async () => { };
|
|
55
|
+
return { setup, run: run, cleanup, type: "create" };
|
|
56
|
+
})();
|
|
57
|
+
function createMoveParticlesPerformanceTest(options) {
|
|
58
|
+
let particles = [];
|
|
59
|
+
const setup = async (n) => {
|
|
60
|
+
particles = createParticlesJS(n);
|
|
61
|
+
if (options.shuffle) {
|
|
62
|
+
shuffleArray(particles);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const run = () => {
|
|
66
|
+
if (options.immutable) {
|
|
67
|
+
for (let i = 0; i < particles.length; i++) {
|
|
68
|
+
const p = particles[i];
|
|
69
|
+
if (p.visible && p.enabled) {
|
|
70
|
+
particles[i] = {
|
|
71
|
+
...p,
|
|
72
|
+
positionX: p.positionX + p.velocityX,
|
|
73
|
+
positionY: p.positionY + p.velocityY,
|
|
74
|
+
positionZ: p.positionZ + p.velocityZ,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
for (let i = 0; i < particles.length; i++) {
|
|
81
|
+
const p = particles[i];
|
|
82
|
+
if (p.visible && p.enabled) {
|
|
83
|
+
p.positionX += p.velocityX;
|
|
84
|
+
p.positionY += p.velocityY;
|
|
85
|
+
p.positionZ += p.velocityZ;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const getVisibleEnabledPositions = () => {
|
|
91
|
+
const values = [];
|
|
92
|
+
for (let i = 0; i < particles.length; i++) {
|
|
93
|
+
const p = particles[i];
|
|
94
|
+
if (p.visible && p.enabled) {
|
|
95
|
+
values.push(p.positionX, p.positionY, p.positionZ);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return values;
|
|
99
|
+
};
|
|
100
|
+
const cleanup = async () => { };
|
|
101
|
+
return { setup, run: run, cleanup, getVisibleEnabledPositions: options.shuffle ? undefined : getVisibleEnabledPositions, type: "move" };
|
|
102
|
+
}
|
|
103
|
+
const move_best = createMoveParticlesPerformanceTest({
|
|
104
|
+
shuffle: false,
|
|
105
|
+
immutable: false,
|
|
106
|
+
});
|
|
107
|
+
const move_worst = createMoveParticlesPerformanceTest({
|
|
108
|
+
shuffle: true,
|
|
109
|
+
immutable: false,
|
|
110
|
+
});
|
|
111
|
+
const move_best_immutable = createMoveParticlesPerformanceTest({
|
|
112
|
+
shuffle: false,
|
|
113
|
+
immutable: true,
|
|
114
|
+
});
|
|
115
|
+
const move_worst_immutable = createMoveParticlesPerformanceTest({
|
|
116
|
+
shuffle: true,
|
|
117
|
+
immutable: true,
|
|
118
|
+
});
|
|
119
|
+
export const vanilla_js = {
|
|
120
|
+
create,
|
|
121
|
+
move_best,
|
|
122
|
+
move_worst,
|
|
123
|
+
};
|
|
124
|
+
export const immutable_js = {
|
|
125
|
+
move_best: move_best_immutable,
|
|
126
|
+
move_worst: move_worst_immutable,
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=vanilla-perf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vanilla-perf.js","sourceRoot":"","sources":["../../src/perftest/vanilla-perf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AACX,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,SAAS,iBAAiB,CAAC,CAAS;IAClC,MAAM,SAAS,GAAU,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAQ;YACpB,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,EAAE;YACR,SAAS,EAAE,CAAC,GAAG,CAAC;YAChB,SAAS,EAAE,CAAC,GAAG,CAAC;YAChB,SAAS,EAAE,CAAC,GAAG,CAAC;YAChB,SAAS,EAAE,CAAC,CAAC;YACb,S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right 2025 Adobe. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.*/
|
|
22
|
+
export * from "./schemas.js";
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AACX,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Schema } from "../core/index.js";
|
|
2
|
+
export declare function Nullable<T extends Schema>(schema: T): {
|
|
3
|
+
oneOf: [T, {
|
|
4
|
+
type: "null";
|
|
5
|
+
}];
|
|
6
|
+
};
|
|
7
|
+
export declare function Tuple<T extends Schema, N extends number>(items: T, length: N): {
|
|
8
|
+
readonly type: "array";
|
|
9
|
+
readonly items: T;
|
|
10
|
+
readonly minItems: N;
|
|
11
|
+
readonly maxItems: N;
|
|
12
|
+
};
|
|
13
|
+
export declare const TrueSchema: {
|
|
14
|
+
readonly const: true;
|
|
15
|
+
};
|
|
16
|
+
export declare const BooleanSchema: {
|
|
17
|
+
readonly type: "boolean";
|
|
18
|
+
};
|
|
19
|
+
export declare const Float32Schema: {
|
|
20
|
+
readonly type: "number";
|
|
21
|
+
readonly precision: 1;
|
|
22
|
+
};
|
|
23
|
+
export declare const Float64Schema: {
|
|
24
|
+
readonly type: "number";
|
|
25
|
+
readonly precision: 2;
|
|
26
|
+
};
|
|
27
|
+
export declare const TimeSchema: {
|
|
28
|
+
readonly type: "number";
|
|
29
|
+
readonly precision: 2;
|
|
30
|
+
};
|
|
31
|
+
export declare const Uint8Schema: {
|
|
32
|
+
readonly type: "integer";
|
|
33
|
+
readonly minimum: 0;
|
|
34
|
+
readonly maximum: 255;
|
|
35
|
+
};
|
|
36
|
+
export declare const Uint16Schema: {
|
|
37
|
+
readonly type: "integer";
|
|
38
|
+
readonly minimum: 0;
|
|
39
|
+
readonly maximum: 65535;
|
|
40
|
+
};
|
|
41
|
+
export declare const Uint32Schema: {
|
|
42
|
+
readonly type: "integer";
|
|
43
|
+
readonly minimum: 0;
|
|
44
|
+
readonly maximum: 4294967295;
|
|
45
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function Nullable(schema) {
|
|
2
|
+
return {
|
|
3
|
+
oneOf: [schema, { type: "null" }],
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
export function Tuple(items, length) {
|
|
7
|
+
return { type: "array", items, minItems: length, maxItems: length };
|
|
8
|
+
}
|
|
9
|
+
export const TrueSchema = {
|
|
10
|
+
const: true,
|
|
11
|
+
};
|
|
12
|
+
export const BooleanSchema = {
|
|
13
|
+
type: "boolean",
|
|
14
|
+
};
|
|
15
|
+
export const Float32Schema = {
|
|
16
|
+
type: "number",
|
|
17
|
+
precision: 1,
|
|
18
|
+
};
|
|
19
|
+
export const Float64Schema = {
|
|
20
|
+
type: "number",
|
|
21
|
+
precision: 2,
|
|
22
|
+
};
|
|
23
|
+
export const TimeSchema = Float64Schema;
|
|
24
|
+
export const Uint8Schema = {
|
|
25
|
+
type: "integer",
|
|
26
|
+
minimum: 0,
|
|
27
|
+
maximum: 0xff,
|
|
28
|
+
};
|
|
29
|
+
export const Uint16Schema = {
|
|
30
|
+
type: "integer",
|
|
31
|
+
minimum: 0,
|
|
32
|
+
maximum: 0xffff,
|
|
33
|
+
};
|
|
34
|
+
export const Uint32Schema = {
|
|
35
|
+
type: "integer",
|
|
36
|
+
minimum: 0,
|
|
37
|
+
maximum: 0xffffffff,
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/schemas/schemas.ts"],"names":[],"mappings":"AAuBA,MAAM,UAAU,QAAQ,CACtB,MAAS;IAET,OAAO;QACL,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,KAAK,CAAqC,KAAQ,EAAE,MAAS;IAC3E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAA4B,CAAC;AAChG,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,IAAI;CACc,CAAC;AAE5B,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,SAAS;CACU,CAAC;AAE5B,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAAC;CACa,CAAC;AAE5B,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAAC;CACa,CAAC;AAE5B,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,IAAI;CACY,CAAC;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,MAAM;CACU,CAAC;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,UAAU;CACM,CAAC"}
|