Initial commit
This commit is contained in:
24
node_modules/alien-signals/benchs/complex.mjs
generated
vendored
Normal file
24
node_modules/alien-signals/benchs/complex.mjs
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { run, bench, boxplot } from 'mitata';
|
||||
import { computed, effect, signal } from '../esm/index.mjs';
|
||||
|
||||
boxplot(() => {
|
||||
bench('complex: $w * $h', function* (state) {
|
||||
const w = state.get('w');
|
||||
const h = state.get('h');
|
||||
const src = signal({ w, h });
|
||||
for (let i = 0; i < w; i++) {
|
||||
let last = src;
|
||||
for (let j = 0; j < h; j++) {
|
||||
const prev = last;
|
||||
last = computed(() => ({ [`${i}-${j}`]: prev.get() }));
|
||||
}
|
||||
effect(() => last.get());
|
||||
}
|
||||
|
||||
yield () => src.set({ upstream: src.get() });
|
||||
})
|
||||
.args('h', [1, 10, 100])
|
||||
.args('w', [1, 10, 100]);
|
||||
});
|
||||
|
||||
run({ format: 'markdown' });
|
||||
23
node_modules/alien-signals/benchs/memoryUsage.mjs
generated
vendored
Normal file
23
node_modules/alien-signals/benchs/memoryUsage.mjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { computed, effect, signal } from '../esm/index.mjs';
|
||||
|
||||
globalThis.gc();
|
||||
const start = process.memoryUsage().heapUsed;
|
||||
|
||||
const w = 100;
|
||||
const h = 100;
|
||||
const src = signal(1);
|
||||
|
||||
for (let i = 0; i < w; i++) {
|
||||
let last = src;
|
||||
for (let j = 0; j < h; j++) {
|
||||
const prev = last;
|
||||
last = computed(() => prev.get() + 1);
|
||||
}
|
||||
effect(() => last.get());
|
||||
}
|
||||
|
||||
src.set(src.get() + 1);
|
||||
|
||||
globalThis.gc();
|
||||
const end = process.memoryUsage().heapUsed;
|
||||
console.log(`Memory Usage: ${((end - start) / 1024).toFixed(2)} KB`);
|
||||
23
node_modules/alien-signals/benchs/propagate.mjs
generated
vendored
Normal file
23
node_modules/alien-signals/benchs/propagate.mjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { run, bench, boxplot } from 'mitata';
|
||||
import { computed, effect, signal } from '../esm/index.mjs';
|
||||
|
||||
boxplot(() => {
|
||||
bench('propagate: $w * $h', function* (state) {
|
||||
const w = state.get('w');
|
||||
const h = state.get('h');
|
||||
const src = signal(1);
|
||||
for (let i = 0; i < w; i++) {
|
||||
let last = src;
|
||||
for (let j = 0; j < h; j++) {
|
||||
const prev = last;
|
||||
last = computed(() => prev.get() + 1);
|
||||
}
|
||||
effect(() => last.get());
|
||||
}
|
||||
yield () => src.set(src.get() + 1);
|
||||
})
|
||||
.args('h', [1, 10, 100])
|
||||
.args('w', [1, 10, 100]);
|
||||
});
|
||||
|
||||
run({ format: 'markdown' });
|
||||
Reference in New Issue
Block a user