Set the decision and its input
The fictional test recipe requires ten reads and ten writes on recordA. Twenty reads onA have the same operation count but no writes, so the recipe does not match. The programme actually replays read/write operations against a local map and counts both types and touched keys.
| Case | Input JSON |
|---|---|
| Base test | {"requiredReads":10,"requiredWrites":10,"requiredKey":"A","operations":[{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"}]} |
Run the supplied comparison
This checks benchmark input validity. The replay is sequential and establishes no actual concurrent contention rate, throughput or production capacity; a matched recipe would still need its separate concurrency trial.
| Path | Output JSON |
|---|---|
| Faulty path | {"reads":20,"writes":0,"valueA":0,"testInputMatches":true} |
| Required path | {"reads":20,"writes":0,"valueA":0,"testInputMatches":false} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
const values=new Map([['A',0],['B',0]]);let reads=0,writes=0;const keys=new Set();
for(const op of i.operations){keys.add(op.key);if(op.kind==='read'){values.get(op.key);reads++;}else if(op.kind==='write'){values.set(op.key,values.get(op.key)+1);writes++;}else throw new Error('Outside the fixed operation grammar');}
const matches=corrected?reads===i.requiredReads&&writes===i.requiredWrites&&keys.size===1&&keys.has(i.requiredKey):reads+writes===i.requiredReads+i.requiredWrites;
return {reads,writes,valueA:values.get('A'),testInputMatches:matches};
};
const cases=[{"input":{"requiredReads":10,"requiredWrites":10,"requiredKey":"A","operations":[{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"}]},"corrected":false,"expected":{"reads":20,"writes":0,"valueA":0,"testInputMatches":true}},{"input":{"requiredReads":10,"requiredWrites":10,"requiredKey":"A","operations":[{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"},{"kind":"read","key":"A"}]},"corrected":true,"expected":{"reads":20,"writes":0,"valueA":0,"testInputMatches":false}},{"input":{"requiredReads":1,"requiredWrites":1,"requiredKey":"A","operations":[{"kind":"read","key":"A"},{"kind":"write","key":"A"}]},"corrected":true,"expected":{"reads":1,"writes":1,"valueA":1,"testInputMatches":true}},{"input":{"requiredReads":1,"requiredWrites":1,"requiredKey":"A","operations":[{"kind":"read","key":"B"},{"kind":"write","key":"B"}]},"corrected":true,"expected":{"reads":1,"writes":1,"valueA":0,"testInputMatches":false}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
One read/one write onA matches its boundary recipe and leaves A1. The same counts onB leave A0 and fail the required shared-record condition.
- Specify transaction mix and key scope
- Replay supplied operations
- Match counts and touched records
Recipe fit alone is not a performance result.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| required hot-record mix | {"requiredReads":1,"requiredWrites":1,"requiredKey":"A","operations":[{"kind":"read","key":"A"},{"kind":"write","key":"A"}]} | {"reads":1,"writes":1,"valueA":1,"testInputMatches":true} |
| same counts but wrong record | {"requiredReads":1,"requiredWrites":1,"requiredKey":"A","operations":[{"kind":"read","key":"B"},{"kind":"write","key":"B"}]} | {"reads":1,"writes":1,"valueA":0,"testInputMatches":false} |
Can base twenty-read evidence support the required read/write test?
Show the worked answer
No. Writes are0 rather than10. Equal totals do not establish the required transaction mix or key distribution.