1+ import assert from 'node:assert/strict' ;
12import { performance } from 'node:perf_hooks' ;
23import { setup , agent , FixtureModel , principal } from '../test/helpers.js' ;
34import { makeBundle } from '../src/lang/bundle.js' ;
@@ -22,13 +23,22 @@ async function main() {
2223 }
2324 const authMs = performance . now ( ) - authStart ;
2425
25- // 2. Measure O(1) Protocol Auto-Detector throughput
26+ // 2. Measure protocol detection on identifiable request shapes.
2627 const payloads = [
2728 { uap : '1.0' , target : 'agent/test' , input : 'hello' } ,
2829 { protocol : 'oaa/1' , agent : 'agent/test' , input : 'hello' } ,
2930 { model : 'agent/test' , input : 'hello' } ,
30- { model : 'agent/test' , messages : [ { role : 'user' , content : 'hello' } ] } ,
31- { model : 'agent/test' , max_tokens : 512 , messages : [ { role : 'user' , content : 'hello' } ] } ,
31+ {
32+ model : 'agent/test' ,
33+ max_completion_tokens : 512 ,
34+ messages : [ { role : 'user' , content : 'hello' } ] ,
35+ } ,
36+ {
37+ model : 'agent/test' ,
38+ max_tokens : 512 ,
39+ top_k : 4 ,
40+ messages : [ { role : 'user' , content : 'hello' } ] ,
41+ } ,
3242 { contents : [ { role : 'user' , parts : [ { text : 'hello' } ] } ] } ,
3343 ] ;
3444 const detectIterations = 100_000 ;
@@ -38,7 +48,7 @@ async function main() {
3848 }
3949 const detectMs = performance . now ( ) - detectStart ;
4050
41- // 3. Compare HotEventRing recentHistory() vs SQLite history() and UAP-NDJSON vs SSE wire size
51+ // 3. Compare streaming wire sizes and measure durable history reads.
4252 const url = await s . listen ( ) ;
4353
4454 const uapRes = await fetch ( `${ url } /v1/uap` , {
@@ -51,6 +61,7 @@ async function main() {
5161 delivery : { stream : true , format : 'uap-ndjson' } ,
5262 } ) ,
5363 } ) ;
64+ assert . equal ( uapRes . status , 200 ) ;
5465 const runId = uapRes . headers . get ( 'x-run-id' ) ! ;
5566 const uapWireBytes = Buffer . byteLength ( await uapRes . text ( ) ) ;
5667
@@ -63,15 +74,10 @@ async function main() {
6374 messages : [ { role : 'user' , content : 'stream test' } ] ,
6475 } ) ,
6576 } ) ;
77+ assert . equal ( chatRes . status , 200 ) ;
6678 const chatWireBytes = Buffer . byteLength ( await chatRes . text ( ) ) ;
6779
6880 const replayIterations = 2_000 ;
69- const ringStart = performance . now ( ) ;
70- for ( let i = 0 ; i < replayIterations ; i ++ ) {
71- s . store . recentHistory ( runId , 0 , 1000 ) ;
72- }
73- const ringMs = performance . now ( ) - ringStart ;
74-
7581 const sqliteStart = performance . now ( ) ;
7682 for ( let i = 0 ; i < replayIterations ; i ++ ) {
7783 s . store . history ( runId , 0 , 1000 ) ;
@@ -84,9 +90,7 @@ async function main() {
8490 uap_ndjson_wire_bytes_2k_output : uapWireBytes ,
8591 openai_chat_sse_wire_bytes_2k_output : chatWireBytes ,
8692 wire_byte_reduction_percent : Number ( ( ( 1 - uapWireBytes / chatWireBytes ) * 100 ) . toFixed ( 1 ) ) ,
87- hot_event_ring_replay_ms_2000_iters : Number ( ringMs . toFixed ( 2 ) ) ,
8893 sqlite_history_replay_ms_2000_iters : Number ( sqliteMs . toFixed ( 2 ) ) ,
89- replay_speedup_factor : Number ( ( sqliteMs / Math . max ( 0.01 , ringMs ) ) . toFixed ( 1 ) ) ,
9094 } ;
9195
9296 process . stdout . write ( JSON . stringify ( summary , null , 2 ) + '\n' ) ;
0 commit comments