flow-execution-performance.test.mjs
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
11 hours ago
| 1 | /** |
| 2 | * Tier 6 — PERFORMANCE: start/advance bounded on fixture. |
| 3 | */ |
| 4 | import { describe, it, beforeEach, afterEach } from 'node:test'; |
| 5 | import assert from 'node:assert/strict'; |
| 6 | import fs from 'node:fs'; |
| 7 | import path from 'node:path'; |
| 8 | import { fileURLToPath } from 'node:url'; |
| 9 | |
| 10 | import { handleFlowRunStartRequest } from '../lib/flow/flow-execution.mjs'; |
| 11 | import { writeExecutionPolicy, seedAutomatableFlow } from './fixtures/flow/execution-helpers.mjs'; |
| 12 | |
| 13 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 14 | const tmpRoot = path.join(__dirname, 'fixtures', 'tmp-flow-execution-perf'); |
| 15 | const P95_MS = 50; |
| 16 | |
| 17 | describe('Flow execution — performance', () => { |
| 18 | beforeEach(() => { |
| 19 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 20 | fs.mkdirSync(tmpRoot, { recursive: true }); |
| 21 | process.env.FLOW_RUN_WRITES_ENABLED = '1'; |
| 22 | }); |
| 23 | |
| 24 | afterEach(() => { |
| 25 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 26 | delete process.env.FLOW_RUN_WRITES_ENABLED; |
| 27 | }); |
| 28 | |
| 29 | it('start run completes within p95 budget', () => { |
| 30 | const dataDir = path.join(tmpRoot, 'perf'); |
| 31 | fs.mkdirSync(dataDir); |
| 32 | writeExecutionPolicy(dataDir); |
| 33 | seedAutomatableFlow(dataDir, 'default'); |
| 34 | const samples = []; |
| 35 | for (let i = 0; i < 20; i += 1) { |
| 36 | const t0 = performance.now(); |
| 37 | const r = handleFlowRunStartRequest({ |
| 38 | dataDir, |
| 39 | vaultId: 'default', |
| 40 | cliScopes: ['personal', 'project', 'org'], |
| 41 | flowId: 'flow_automatable_test', |
| 42 | flowVersion: '1.0.0', |
| 43 | }); |
| 44 | samples.push(performance.now() - t0); |
| 45 | assert.equal(r.ok, true); |
| 46 | } |
| 47 | samples.sort((a, b) => a - b); |
| 48 | const p95 = samples[Math.floor(samples.length * 0.95) - 1]; |
| 49 | assert.ok(p95 < P95_MS, `p95 ${p95}ms exceeds ${P95_MS}ms`); |
| 50 | }); |
| 51 | }); |
File History
1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
11 hours ago