@@ -186,9 +186,9 @@ setSummaryStats view SummaryStats{..} hasHeapEvents = do
186186setTimeStats :: SummaryView -> TimeStats -> IO ()
187187setTimeStats SummaryView {.. } TimeStats {.. } =
188188 mapM_ (\ (label, text) -> set label [ labelText := text ])
189- [ (labelTimeTotal , showFFloat ( Just 2 ) (timeToSecondsDbl timeTotal) " s " )
190- , (labelTimeMutator , showFFloat ( Just 2 ) (timeToSecondsDbl timeMutator) " s " )
191- , (labelTimeGC , showFFloat ( Just 2 ) (timeToSecondsDbl timeGC) " s " )
189+ [ (labelTimeTotal , showTimeWithUnit timeTotal)
190+ , (labelTimeMutator , showTimeWithUnit timeMutator)
191+ , (labelTimeGC , showTimeWithUnit timeGC)
192192 , (labelTimeProductivity, showFFloat (Just 1 ) (timeProductivity * 100 ) " % of mutator vs total" )
193193 ]
194194
@@ -563,6 +563,17 @@ sparkStats StatsAccum{dsparkTable} =
563563
564564------------------------------------------------------------------------------
565565
566+ showTimeWithUnit :: Integral a => a -> String
567+ showTimeWithUnit t =
568+ showFFloat (Just 3 ) t'' unit
569+ where
570+ (t'', unit) =
571+ case timeToSecondsDbl t of
572+ t' | t' < 1e-6 -> (t' / 1e-9 , " ns" )
573+ | t' < 1e-3 -> (t' / 1e-6 , " μs" )
574+ | t' < 1 -> (t' / 1e-3 , " ms" )
575+ | otherwise -> (t', " s" )
576+
566577timeToSecondsDbl :: Integral a => a -> Double
567578timeToSecondsDbl t = timeToSeconds $ fromIntegral t
568579
0 commit comments