@@ -25,11 +25,18 @@ type Sample = {
2525 maxRssMb : number | null ;
2626 exitCode : number | null ;
2727 signal : string | null ;
28+ startedAt ?: string ;
29+ endedAt ?: string ;
2830 timedOut ?: boolean ;
2931 stdoutTail ?: string ;
3032 stderrTail ?: string ;
3133} ;
3234
35+ type CaseRuns = {
36+ warmupSamples : Sample [ ] ;
37+ samples : Sample [ ] ;
38+ } ;
39+
3340type SummaryStats = {
3441 avg : number ;
3542 p50 : number ;
@@ -58,6 +65,7 @@ type SuiteResult = {
5865 firstOutputBudgetMs : number | null ;
5966 exitBudgetMs : number | null ;
6067 } | null ;
68+ warmupSamples ?: Sample [ ] ;
6169 samples : Sample [ ] ;
6270 summary : CaseSummary ;
6371 } > ;
@@ -754,6 +762,7 @@ async function runSample(params: {
754762 params . entry ,
755763 ...params . commandCase . args ,
756764 ] ;
765+ const startedAt = new Date ( ) ;
757766 const started = process . hrtime . bigint ( ) ;
758767 let firstOutputMs : number | null = null ;
759768 let stdout = "" ;
@@ -798,6 +807,8 @@ async function runSample(params: {
798807 ms,
799808 firstOutputMs,
800809 maxRssMb : parseMaxRssMb ( stderr ) ,
810+ startedAt : startedAt . toISOString ( ) ,
811+ endedAt : new Date ( ) . toISOString ( ) ,
801812 ...( timedOut ? { timedOut } : { } ) ,
802813 ...sample ,
803814 } ) ;
@@ -956,7 +967,8 @@ async function runCase(params: {
956967 cpuProfDir ?: string ;
957968 heapProfDir ?: string ;
958969 rssHookPath : string ;
959- } ) : Promise < Sample [ ] > {
970+ } ) : Promise < CaseRuns > {
971+ const warmupSamples : Sample [ ] = [ ] ;
960972 const samples : Sample [ ] = [ ] ;
961973 const totalRuns = params . warmup + params . runs ;
962974 const caseRunRoot =
@@ -967,11 +979,12 @@ async function runCase(params: {
967979 for ( let i = 0 ; i < totalRuns ; i += 1 ) {
968980 const sample = await runSample ( { ...params , runRoot : caseRunRoot } ) ;
969981 if ( i < params . warmup ) {
982+ warmupSamples . push ( sample ) ;
970983 continue ;
971984 }
972985 samples . push ( sample ) ;
973986 }
974- return samples ;
987+ return { warmupSamples , samples } ;
975988 } finally {
976989 if ( caseRunRoot ) {
977990 rmSync ( caseRunRoot , { recursive : true , force : true } ) ;
@@ -1064,30 +1077,34 @@ export function collectFailedSamples(result: SuiteResult): string[] {
10641077 for ( const commandCase of result . cases ) {
10651078 if ( commandCase . samples . length === 0 ) {
10661079 failures . push ( `${ result . entry } ${ commandCase . id } : no measured samples` ) ;
1067- continue ;
10681080 }
1069- for ( const [ sampleIndex , sample ] of commandCase . samples . entries ( ) ) {
1070- const label = `${ result . entry } ${ commandCase . id } sample ${ sampleIndex + 1 } ` ;
1071- const expectedExitCodes = new Set ( commandCase . expectedExitCodes ?? [ 0 ] ) ;
1072- if ( sample . timedOut === true ) {
1073- failures . push ( `${ label } : timed out` ) ;
1074- } else if ( sample . signal !== null ) {
1075- failures . push ( `${ label } : exited via signal ${ sample . signal } ` ) ;
1076- } else if ( ! expectedExitCodes . has ( sample . exitCode ?? - 1 ) ) {
1077- failures . push ( `${ label } : exited with code ${ String ( sample . exitCode ) } ` ) ;
1078- } else if ( sample . maxRssMb === null ) {
1079- failures . push ( `${ label } : did not report max RSS` ) ;
1080- } else if ( sample . exitCode !== 0 ) {
1081- const output = `${ sample . stdoutTail ?? "" } \n${ sample . stderrTail ?? "" } ` ;
1082- const missing = ( commandCase . expectedNonzeroOutputIncludes ?? [ ] ) . filter (
1083- ( snippet ) => ! output . includes ( snippet ) ,
1084- ) ;
1085- if ( missing . length > 0 ) {
1086- failures . push (
1087- `${ label } : exited with expected code ${ String (
1088- sample . exitCode ,
1089- ) } but output did not match expected clean-state markers (${ missing . join ( ", " ) } )`,
1081+ for ( const [ sampleKind , samples ] of [
1082+ [ "warmup" , commandCase . warmupSamples ?? [ ] ] ,
1083+ [ "sample" , commandCase . samples ] ,
1084+ ] as const ) {
1085+ for ( const [ sampleIndex , sample ] of samples . entries ( ) ) {
1086+ const label = `${ result . entry } ${ commandCase . id } ${ sampleKind } ${ sampleIndex + 1 } ` ;
1087+ const expectedExitCodes = new Set ( commandCase . expectedExitCodes ?? [ 0 ] ) ;
1088+ if ( sample . timedOut === true ) {
1089+ failures . push ( `${ label } : timed out` ) ;
1090+ } else if ( sample . signal !== null ) {
1091+ failures . push ( `${ label } : exited via signal ${ sample . signal } ` ) ;
1092+ } else if ( ! expectedExitCodes . has ( sample . exitCode ?? - 1 ) ) {
1093+ failures . push ( `${ label } : exited with code ${ String ( sample . exitCode ) } ` ) ;
1094+ } else if ( sample . maxRssMb === null ) {
1095+ failures . push ( `${ label } : did not report max RSS` ) ;
1096+ } else if ( sample . exitCode !== 0 ) {
1097+ const output = `${ sample . stdoutTail ?? "" } \n${ sample . stderrTail ?? "" } ` ;
1098+ const missing = ( commandCase . expectedNonzeroOutputIncludes ?? [ ] ) . filter (
1099+ ( snippet ) => ! output . includes ( snippet ) ,
10901100 ) ;
1101+ if ( missing . length > 0 ) {
1102+ failures . push (
1103+ `${ label } : exited with expected code ${ String (
1104+ sample . exitCode ,
1105+ ) } but output did not match expected clean-state markers (${ missing . join ( ", " ) } )`,
1106+ ) ;
1107+ }
10911108 }
10921109 }
10931110 }
@@ -1102,7 +1119,7 @@ async function buildSuiteResult(params: {
11021119} ) : Promise < SuiteResult > {
11031120 const cases = [ ] ;
11041121 for ( const commandCase of params . options . cases ) {
1105- const samples = await runCase ( {
1122+ const { warmupSamples , samples } = await runCase ( {
11061123 entry : params . entry ,
11071124 commandCase,
11081125 runs : params . options . runs ,
@@ -1129,6 +1146,7 @@ async function buildSuiteResult(params: {
11291146 exitBudgetMs : commandCase . exitBudgetMs ?? null ,
11301147 }
11311148 : null ,
1149+ warmupSamples,
11321150 samples,
11331151 summary : summarizeSamples ( samples ) ,
11341152 } ) ;
0 commit comments