@@ -16,22 +16,11 @@ import type { AgentEvalResults, EvalDataV2, ProgressEvent } from './types'
1616export async function runBuffBench ( options : {
1717 evalDataPath : string
1818 agents : string [ ]
19- outputPath ?: string
2019 commitConcurrency ?: number
2120 onProgress ?: ( event : ProgressEvent ) => void
2221 client ?: CodebuffClient
23- } ) : Promise < {
24- agents : Record < string , AgentEvalResults >
25- timestamp : string
26- totalDuration : number
27- } > {
28- const {
29- evalDataPath,
30- agents,
31- outputPath,
32- commitConcurrency = 1 ,
33- onProgress,
34- } = options
22+ } ) {
23+ const { evalDataPath, agents, commitConcurrency = 1 , onProgress } = options
3524
3625 const evalData : EvalDataV2 = JSON . parse (
3726 fs . readFileSync ( evalDataPath , 'utf-8' ) ,
@@ -49,8 +38,7 @@ export async function runBuffBench(options: {
4938
5039 // Create logs directory with current date and time
5140 const date = new Date ( ) . toISOString ( ) . replace ( / : / g, '-' ) . slice ( 0 , 16 ) // YYYY-MM-DDTHH-MM
52- const outputDir = outputPath ? path . dirname ( outputPath ) : __dirname
53- const logsDir = path . join ( outputDir , 'logs' , date )
41+ const logsDir = path . join ( __dirname , 'logs' , date )
5442 if ( ! fs . existsSync ( logsDir ) ) {
5543 fs . mkdirSync ( logsDir , { recursive : true } )
5644 }
@@ -272,7 +260,7 @@ export async function runBuffBench(options: {
272260 }
273261 }
274262
275- for ( const [ agentId , agentData ] of Object . entries ( results ) ) {
263+ for ( const [ _agentId , agentData ] of Object . entries ( results ) ) {
276264 const successfulRuns = agentData . runs . filter ( ( r ) => ! r . error )
277265 const totalRuns = agentData . runs . length
278266
@@ -293,38 +281,22 @@ export async function runBuffBench(options: {
293281 : 0
294282 }
295283
296- const result = {
297- agents : results ,
298- timestamp : new Date ( ) . toISOString ( ) ,
299- totalDuration : Date . now ( ) - startTime ,
300- }
301-
302- if ( outputPath ) {
303- const outputDir = path . dirname ( outputPath )
304- if ( ! fs . existsSync ( outputDir ) ) {
305- fs . mkdirSync ( outputDir , { recursive : true } )
306- }
307-
308- fs . writeFileSync ( outputPath , JSON . stringify ( result , null , 2 ) )
309- console . log ( `\nResults written to ${ outputPath } ` )
310- }
311-
312284 const logFiles = fs . readdirSync ( logsDir )
313285
314286 const finalResults = {
315287 metadata : {
316- timestamp : result . timestamp ,
288+ timestamp : new Date ( ) . toISOString ( ) ,
317289 evalDataPath,
318290 agentsTested : agents ,
319291 commitsEvaluated : commitsToRun . length ,
320292 totalCommitsInEval : evalData . evalCommits . length ,
321293 repoUrl : evalData . repoUrl ,
322294 initCommand : evalData . initCommand ,
323- totalDuration : result . totalDuration ,
295+ totalDuration : Date . now ( ) - startTime ,
324296 logsDirectory : logsDir ,
325297 files : logFiles ,
326298 } ,
327- ...result . agents ,
299+ ...results ,
328300 }
329301
330302 const finalResultsPath = path . join ( logsDir , 'FINAL_RESULTS.json' )
@@ -344,5 +316,5 @@ export async function runBuffBench(options: {
344316 )
345317 }
346318
347- return result
319+ return finalResults
348320}
0 commit comments