@@ -37,7 +37,9 @@ import Development.IDE.Test (getBuildEdgesCount,
37
37
getBuildKeysBuilt ,
38
38
getBuildKeysChanged ,
39
39
getBuildKeysVisited ,
40
- getStoredKeys )
40
+ getStoredKeys ,
41
+ getRebuildsCount ,
42
+ )
41
43
import Development.IDE.Test.Diagnostic
42
44
import Development.Shake (CmdOption (Cwd , FileStdout ),
43
45
cmd_ )
@@ -329,12 +331,15 @@ runBenchmarksFun dir allBenchmarks = do
329
331
, " setup"
330
332
, " userTime"
331
333
, " delayedTime"
334
+ , " firstBuildTime"
335
+ , " averageTimePerResponse"
332
336
, " totalTime"
333
337
, " buildRulesBuilt"
334
338
, " buildRulesChanged"
335
339
, " buildRulesVisited"
336
340
, " buildRulesTotal"
337
341
, " buildEdges"
342
+ , " ghcRebuilds"
338
343
]
339
344
rows =
340
345
[ [ name,
@@ -344,15 +349,21 @@ runBenchmarksFun dir allBenchmarks = do
344
349
show runSetup',
345
350
show userWaits,
346
351
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)),
347
356
show runExperiment,
348
357
show rulesBuilt,
349
358
show rulesChanged,
350
359
show rulesVisited,
351
360
show rulesTotal,
352
- show edgesTotal
361
+ show edgesTotal,
362
+ show rebuildsTotal
353
363
]
354
364
| (Bench {name, samples}, BenchRun {.. }) <- results,
355
365
let runSetup' = if runSetup < 0.01 then 0 else runSetup
366
+ modules = fromIntegral $ length $ exampleModules $ example ? config
356
367
]
357
368
csv = unlines $ map (intercalate " , " ) (headers : rows)
358
369
writeFile (outputCSV ? config) csv
@@ -369,12 +380,14 @@ runBenchmarksFun dir allBenchmarks = do
369
380
showDuration runSetup',
370
381
showDuration userWaits,
371
382
showDuration delayedWork,
383
+ showDuration firstResponse,
372
384
showDuration runExperiment,
373
385
show rulesBuilt,
374
386
show rulesChanged,
375
387
show rulesVisited,
376
388
show rulesTotal,
377
- show edgesTotal
389
+ show edgesTotal,
390
+ show rebuildsTotal
378
391
]
379
392
| (Bench {name, samples}, BenchRun {.. }) <- results,
380
393
let runSetup' = if runSetup < 0.01 then 0 else runSetup
@@ -420,16 +433,19 @@ data BenchRun = BenchRun
420
433
runExperiment :: ! Seconds ,
421
434
userWaits :: ! Seconds ,
422
435
delayedWork :: ! Seconds ,
436
+ firstResponse :: ! Seconds ,
437
+ firstResponseDelayed :: ! Seconds ,
423
438
rulesBuilt :: ! Int ,
424
439
rulesChanged :: ! Int ,
425
440
rulesVisited :: ! Int ,
426
441
rulesTotal :: ! Int ,
427
442
edgesTotal :: ! Int ,
443
+ rebuildsTotal :: ! Int ,
428
444
success :: ! Bool
429
445
}
430
446
431
447
badRun :: 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
433
449
434
450
waitForProgressStart :: Session ()
435
451
waitForProgressStart = void $ do
@@ -482,26 +498,28 @@ runBench runSess b = handleAny (\e -> print e >> return badRun)
482
498
483
499
liftIO $ output $ " Running " <> name <> " benchmark"
484
500
(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
487
503
(t, res) <- duration $ experiment docs
488
504
if not res
489
505
then return Nothing
490
506
else do
491
507
output (showDuration t)
492
508
-- Wait for the delayed actions to finish
493
509
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
495
512
496
513
(runExperiment, result) <- duration $ loop 0 0 samples
497
514
let success = isJust result
498
- (userWaits, delayedWork) = fromMaybe (0 ,0 ) result
515
+ (userWaits, delayedWork, (firstResponse, firstResponseDelayed)) = fromMaybe (0 ,0 ,( 0 , 0 ) ) result
499
516
500
517
rulesTotal <- length <$> getStoredKeys
501
518
rulesBuilt <- either (const 0 ) length <$> getBuildKeysBuilt
502
519
rulesChanged <- either (const 0 ) length <$> getBuildKeysChanged
503
520
rulesVisited <- either (const 0 ) length <$> getBuildKeysVisited
504
521
edgesTotal <- fromRight 0 <$> getBuildEdgesCount
522
+ rebuildsTotal <- fromRight 0 <$> getRebuildsCount
505
523
506
524
return BenchRun {.. }
507
525
0 commit comments