test: add PI release proof harness
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { act, render } from '@testing-library/react';
|
||||
import { mkdtemp, rm } from 'node:fs/promises';
|
||||
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
||||
import { createServer } from 'node:http';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
@@ -36,6 +36,16 @@ function percentile95(values: number[]): number {
|
||||
return ordered[Math.ceil(ordered.length * 0.95) - 1] ?? Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
function summarize(values: number[]): { samples: number; p50: number; p95: number; max: number } {
|
||||
const ordered = [...values].sort((left, right) => left - right);
|
||||
return {
|
||||
samples: ordered.length,
|
||||
p50: ordered[Math.ceil(ordered.length * 0.5) - 1] ?? Number.POSITIVE_INFINITY,
|
||||
p95: percentile95(ordered),
|
||||
max: ordered.at(-1) ?? Number.POSITIVE_INFINITY,
|
||||
};
|
||||
}
|
||||
|
||||
function pressurePatch(seq: number): ConversationPatch {
|
||||
if (seq === 1) {
|
||||
return {
|
||||
@@ -203,7 +213,7 @@ describe('REN-008 coding timeline pressure', () => {
|
||||
latencies.push(performance.now() - startedAt);
|
||||
}
|
||||
const measuredReactCommits = reactCommits - initialCommits;
|
||||
const p95Ms = percentile95(latencies);
|
||||
const mainToReactMs = summarize(latencies);
|
||||
const metrics = {
|
||||
runtimePatchItems,
|
||||
patchBatches,
|
||||
@@ -211,7 +221,8 @@ describe('REN-008 coding timeline pressure', () => {
|
||||
rendererTransactions,
|
||||
reactCommits: measuredReactCommits,
|
||||
wireBytes,
|
||||
mainToReactP95Ms: p95Ms,
|
||||
mainToReactMs,
|
||||
mainToReactP95Ms: mainToReactMs.p95,
|
||||
};
|
||||
console.info('REN-008 metrics', metrics);
|
||||
expect(metrics.runtimePatchItems).toBe(100);
|
||||
@@ -225,6 +236,8 @@ describe('REN-008 coding timeline pressure', () => {
|
||||
.entriesByConversationId[conversation.id]?.reducer.snapshot?.cursor.seq).toBe(100);
|
||||
view.unmount();
|
||||
unsubscribe();
|
||||
const reportPath = process.env.MAKELORE_PI_PERF_PRESSURE_FRAGMENT;
|
||||
if (reportPath) await writeFile(reportPath, `${JSON.stringify(metrics, null, 2)}\n`);
|
||||
} finally {
|
||||
controller.abort();
|
||||
await reader.cancel().catch(() => undefined);
|
||||
|
||||
Reference in New Issue
Block a user