@@ -37,7 +37,9 @@ import Development.IDE.Test (getBuildEdgesCount,
3737 getBuildKeysBuilt ,
3838 getBuildKeysChanged ,
3939 getBuildKeysVisited ,
40- getStoredKeys )
40+ getStoredKeys ,
41+ getRebuildsCount ,
42+ )
4143import Development.IDE.Test.Diagnostic
4244import Development.Shake (CmdOption (Cwd , FileStdout ),
4345 cmd_ )
@@ -329,12 +331,15 @@ runBenchmarksFun dir allBenchmarks = do
329331 , " setup"
330332 , " userTime"
331333 , " delayedTime"
334+ , " firstBuildTime"
335+ , " averageTimePerResponse"
332336 , " totalTime"
333337 , " buildRulesBuilt"
334338 , " buildRulesChanged"
335339 , " buildRulesVisited"
336340 , " buildRulesTotal"
337341 , " buildEdges"
342+ , " ghcRebuilds"
338343 ]
339344 rows =
340345 [ [ name,
@@ -344,15 +349,21 @@ runBenchmarksFun dir allBenchmarks = do
344349 show runSetup',
345350 show userWaits,
346351 show delayedWork,
352+ show $ firstResponse+ firstResponseDelayed,
353+ -- Exclude first response as it has a lot of setup time included
354+ -- Assume that number of requests = number of modules * number of samples
355+ show ((userWaits - firstResponse)/ ((fromIntegral samples - 1 )* modules)),
347356 show runExperiment,
348357 show rulesBuilt,
349358 show rulesChanged,
350359 show rulesVisited,
351360 show rulesTotal,
352- show edgesTotal
361+ show edgesTotal,
362+ show rebuildsTotal
353363 ]
354364 | (Bench {name, samples}, BenchRun {.. }) <- results,
355365 let runSetup' = if runSetup < 0.01 then 0 else runSetup
366+ modules = fromIntegral $ length $ exampleModules $ example ? config
356367 ]
357368 csv = unlines $ map (intercalate " , " ) (headers : rows)
358369 writeFile (outputCSV ? config) csv
@@ -369,12 +380,14 @@ runBenchmarksFun dir allBenchmarks = do
369380 showDuration runSetup',
370381 showDuration userWaits,
371382 showDuration delayedWork,
383+ showDuration firstResponse,
372384 showDuration runExperiment,
373385 show rulesBuilt,
374386 show rulesChanged,
375387 show rulesVisited,
376388 show rulesTotal,
377- show edgesTotal
389+ show edgesTotal,
390+ show rebuildsTotal
378391 ]
379392 | (Bench {name, samples}, BenchRun {.. }) <- results,
380393 let runSetup' = if runSetup < 0.01 then 0 else runSetup
@@ -420,16 +433,19 @@ data BenchRun = BenchRun
420433 runExperiment :: ! Seconds ,
421434 userWaits :: ! Seconds ,
422435 delayedWork :: ! Seconds ,
436+ firstResponse :: ! Seconds ,
437+ firstResponseDelayed :: ! Seconds ,
423438 rulesBuilt :: ! Int ,
424439 rulesChanged :: ! Int ,
425440 rulesVisited :: ! Int ,
426441 rulesTotal :: ! Int ,
427442 edgesTotal :: ! Int ,
443+ rebuildsTotal :: ! Int ,
428444 success :: ! Bool
429445 }
430446
431447badRun :: BenchRun
432- badRun = BenchRun 0 0 0 0 0 0 0 0 0 0 False
448+ badRun = BenchRun 0 0 0 0 0 0 0 0 0 0 0 0 0 False
433449
434450waitForProgressStart :: Session ()
435451waitForProgressStart = void $ do
@@ -482,26 +498,28 @@ runBench runSess b = handleAny (\e -> print e >> return badRun)
482498
483499 liftIO $ output $ " Running " <> name <> " benchmark"
484500 (runSetup, () ) <- duration $ benchSetup docs
485- let loop ! userWaits ! delayedWork 0 = return $ Just (userWaits, delayedWork)
486- loop ! userWaits ! delayedWork n = do
501+ let loop' ( Just timeForFirstResponse) ! userWaits ! delayedWork 0 = return $ Just (userWaits, delayedWork, timeForFirstResponse )
502+ loop' timeForFirstResponse ! userWaits ! delayedWork n = do
487503 (t, res) <- duration $ experiment docs
488504 if not res
489505 then return Nothing
490506 else do
491507 output (showDuration t)
492508 -- Wait for the delayed actions to finish
493509 td <- waitForBuildQueue
494- loop (userWaits+ t) (delayedWork+ td) (n - 1 )
510+ loop' (timeForFirstResponse <|> (Just (t,td))) (userWaits+ t) (delayedWork+ td) (n - 1 )
511+ loop = loop' Nothing
495512
496513 (runExperiment, result) <- duration $ loop 0 0 samples
497514 let success = isJust result
498- (userWaits, delayedWork) = fromMaybe (0 ,0 ) result
515+ (userWaits, delayedWork, (firstResponse, firstResponseDelayed)) = fromMaybe (0 ,0 ,( 0 , 0 ) ) result
499516
500517 rulesTotal <- length <$> getStoredKeys
501518 rulesBuilt <- either (const 0 ) length <$> getBuildKeysBuilt
502519 rulesChanged <- either (const 0 ) length <$> getBuildKeysChanged
503520 rulesVisited <- either (const 0 ) length <$> getBuildKeysVisited
504521 edgesTotal <- fromRight 0 <$> getBuildEdgesCount
522+ rebuildsTotal <- fromRight 0 <$> getRebuildsCount
505523
506524 return BenchRun {.. }
507525
0 commit comments