Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions packages/js-krauset/package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"name": "js-framework-benchmark-react-supergrain",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build-prod": "vite build",
"typecheck": "tsc --noEmit",
"test": "pnpm build-prod && vitest run --config vitest.dist.config.ts src/dist.test.ts",
"test:perf": "pnpm build-prod && vitest run --config vitest.dist.config.ts src/perf.test.ts --reporter=verbose 2>&1 | tee perf-results.txt",
"perf:stats": "npx tsx perf-stats.ts",
"perf:compare": "npx tsx perf-compare.ts",
"perf:profile": "pnpm build-prod && PROFILE=1 vitest run --config vitest.dist.config.ts src/perf.test.ts",
"perf:analyze": "node perf-profile.ts"
},
"dependencies": {
"@supergrain/kernel": "workspace:*",
"react": "19.2.4",
"react-dom": "19.2.4"
},
"devDependencies": {
"@rollup/plugin-strip": "^3.0.4",
"@types/node": "^22.18.3",
"@types/ramda": "^0.31.1",
"@types/react": "^19.1.13",
"@types/react-dom": "^19.1.9",
"@vitejs/plugin-react": "^4.7.0",
"@vitest/browser": "4.1.0",
"playwright": "^1.55.0",
"ramda": "^0.32.0",
"typescript": "^5.9.2",
"vite": "^7.1.5",
"vite-plugin-dts": "^4.5.4",
"vitest": "4.1.0"
},
"js-framework-benchmark": {
"frameworkVersionFromPackage": "react",
"frameworkHomeURL": "https://reactjs.org/"
}
"name": "js-framework-benchmark-react-supergrain",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build-prod": "vite build",
"typecheck": "tsc --noEmit",
"test": "pnpm build-prod && vitest run --config vitest.dist.config.ts src/dist.test.ts",
"test:perf": "pnpm build-prod && vitest run --config vitest.dist.config.ts src/perf.test.ts --reporter=verbose 2>&1 | tee perf-results.txt",
"perf:stats": "npx tsx perf-stats.ts",
"perf:compare": "npx tsx perf-compare.ts",
"perf:profile": "pnpm build-prod && PROFILE=1 vitest run --config vitest.dist.config.ts src/perf.test.ts",
"perf:analyze": "node perf-profile.ts"
},
"dependencies": {
"@supergrain/kernel": "workspace:*",
"react": "19.2.4",
"react-dom": "19.2.4"
},
"devDependencies": {
"@rollup/plugin-strip": "^3.0.4",
"@types/node": "^22.18.3",
"@types/ramda": "^0.31.1",
"@types/react": "^19.1.13",
"@types/react-dom": "^19.1.9",
"@vitejs/plugin-react": "^4.7.0",
"@vitest/browser": "4.1.0",
"playwright": "^1.55.0",
"ramda": "^0.32.0",
"typescript": "^5.9.2",
"vite": "^7.1.5",
"vite-plugin-dts": "^4.5.4",
"vitest": "4.1.0"
},
"js-framework-benchmark": {
"frameworkVersionFromPackage": "react",
"frameworkHomeURL": "https://reactjs.org/"
}
}
10 changes: 8 additions & 2 deletions packages/js-krauset/perf-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,21 @@ for (const benchName of benchmarkNames) {
const samples = runs.map((run: any) => run.results.find((r: any) => r.name === benchName));
const benchmark: any = {};
for (const key of numericKeys) {
benchmark[key] = stats(samples.map((s: any) => s[key]), trimCount);
benchmark[key] = stats(
samples.map((s: any) => s[key]),
trimCount,
);
}
output.benchmarks[benchName] = benchmark;
}

const totalSamples = runs.map((run: any) => run.totals);
output.totals = {} as any;
for (const key of numericKeys.filter((k) => k in runs[0].totals)) {
output.totals[key] = stats(totalSamples.map((t: any) => t[key]), trimCount);
output.totals[key] = stats(
totalSamples.map((t: any) => t[key]),
trimCount,
);
}

const outPath = resolve(dir, `perf-stats-${name}.json`);
Expand Down
5 changes: 3 additions & 2 deletions packages/kernel/src/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
getNodesIfExist,
isWrappable,
unwrap,
type ReactiveTagged,
type Signal,
} from "./core";
import { profileSignalRead, profileSignalSkip, profileSignalWrite } from "./profiler";
Expand Down Expand Up @@ -108,7 +109,7 @@ function bumpVersionSignal(target: object): void {

export function createReactiveMap<K, V>(rawTarget: Map<K, V>): Map<K, V> {
// Primary proxy cache: $PROXY stored directly on the raw target.
const existing = (rawTarget as any)[$PROXY] as Map<K, V> | undefined;
const existing = (rawTarget as ReactiveTagged)[$PROXY] as Map<K, V> | undefined;
if (existing) return existing;
// Fallback for sealed Maps where defineProperty($PROXY) fails.
const existingSealed = sealedCollectionCache.get(rawTarget) as Map<K, V> | undefined;
Expand Down Expand Up @@ -352,7 +353,7 @@ export function createReactiveMap<K, V>(rawTarget: Map<K, V>): Map<K, V> {

export function createReactiveSet<T>(rawTarget: Set<T>): Set<T> {
// Primary proxy cache: $PROXY stored directly on the raw target.
const existing = (rawTarget as any)[$PROXY] as Set<T> | undefined;
const existing = (rawTarget as ReactiveTagged)[$PROXY] as Set<T> | undefined;
if (existing) return existing;
// Fallback for sealed Sets where defineProperty($PROXY) fails.
const existingSealed = sealedCollectionCache.get(rawTarget) as Set<T> | undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/kernel/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface ReactiveTagged {
[$PROXY]?: object;
[$NODE]?: DataNodes;
[$TRACK]?: object;
[$MUTATORS]?: Record<string, (...args: Array<unknown>) => unknown>;
}

export type DataNodes = Record<PropertyKey, Signal<unknown>>;
Expand Down
8 changes: 2 additions & 6 deletions packages/kernel/src/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,8 @@ function trackArrayVersion(value: unknown): void {
// Create (or retrieve) the per-array mutator wrapper cache stored as a hidden
// $MUTATORS property on the raw array. Extracted to keep the proxy get handler
// shallow enough to satisfy the max-depth lint rule.
function getMutatorCache(
target: object,
): Record<string, (...args: Array<unknown>) => unknown> {
let cache = (target as any)[$MUTATORS] as
| Record<string, (...args: Array<unknown>) => unknown>
| undefined;
function getMutatorCache(target: object): Record<string, (...args: Array<unknown>) => unknown> {
let cache = (target as ReactiveTagged)[$MUTATORS];
if (!cache) {
cache = Object.create(null) as Record<string, (...args: Array<unknown>) => unknown>;
try {
Expand Down
Loading