{-# LINE 1 "GHC/Stats.hsc" #-}
{-# LANGUAGE Trustworthy #-}
{-# LINE 2 "GHC/Stats.hsc" #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
module GHC.Stats
( GCStats(..)
, getGCStats
, getGCStatsEnabled
) where
import Control.Monad
import Data.Int
import GHC.Base
import GHC.Read ( Read )
import GHC.Show ( Show )
import GHC.IO.Exception
import Foreign.Marshal.Alloc
import Foreign.Storable
import Foreign.Ptr
{-# LINE 32 "GHC/Stats.hsc" #-}
foreign import ccall "getGCStats" getGCStats_ :: Ptr () -> IO ()
foreign import ccall "getGCStatsEnabled" getGCStatsEnabled :: IO Bool
data GCStats = GCStats
{ bytesAllocated :: !Int64
, numGcs :: !Int64
, maxBytesUsed :: !Int64
, numByteUsageSamples :: !Int64
, cumulativeBytesUsed :: !Int64
, bytesCopied :: !Int64
, currentBytesUsed :: !Int64
, currentBytesSlop :: !Int64
, maxBytesSlop :: !Int64
, peakMegabytesAllocated :: !Int64
, mutatorCpuSeconds :: !Double
, mutatorWallSeconds :: !Double
, gcCpuSeconds :: !Double
, gcWallSeconds :: !Double
, cpuSeconds :: !Double
, wallSeconds :: !Double
, parTotBytesCopied :: !Int64
, parMaxBytesCopied :: !Int64
} deriving (Show, Read)
getGCStats :: IO GCStats
getGCStats = do
statsEnabled <- getGCStatsEnabled
unless statsEnabled . ioError $ IOError
Nothing
UnsupportedOperation
""
"getGCStats: GC stats not enabled. Use `+RTS -T -RTS' to enable them."
Nothing
Nothing
allocaBytes ((144)) $ \p -> do
{-# LINE 104 "GHC/Stats.hsc" #-}
getGCStats_ p
bytesAllocated <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p
{-# LINE 106 "GHC/Stats.hsc" #-}
numGcs <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 107 "GHC/Stats.hsc" #-}
numByteUsageSamples <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p
{-# LINE 108 "GHC/Stats.hsc" #-}
maxBytesUsed <- ((\hsc_ptr -> peekByteOff hsc_ptr 24)) p
{-# LINE 109 "GHC/Stats.hsc" #-}
cumulativeBytesUsed <- ((\hsc_ptr -> peekByteOff hsc_ptr 32)) p
{-# LINE 110 "GHC/Stats.hsc" #-}
bytesCopied <- ((\hsc_ptr -> peekByteOff hsc_ptr 40)) p
{-# LINE 111 "GHC/Stats.hsc" #-}
currentBytesUsed <- ((\hsc_ptr -> peekByteOff hsc_ptr 48)) p
{-# LINE 112 "GHC/Stats.hsc" #-}
currentBytesSlop <- ((\hsc_ptr -> peekByteOff hsc_ptr 56)) p
{-# LINE 113 "GHC/Stats.hsc" #-}
maxBytesSlop <- ((\hsc_ptr -> peekByteOff hsc_ptr 64)) p
{-# LINE 114 "GHC/Stats.hsc" #-}
peakMegabytesAllocated <- ((\hsc_ptr -> peekByteOff hsc_ptr 72)) p
{-# LINE 115 "GHC/Stats.hsc" #-}
mutatorCpuSeconds <- ((\hsc_ptr -> peekByteOff hsc_ptr 96)) p
{-# LINE 120 "GHC/Stats.hsc" #-}
mutatorWallSeconds <- ((\hsc_ptr -> peekByteOff hsc_ptr 104)) p
{-# LINE 121 "GHC/Stats.hsc" #-}
gcCpuSeconds <- ((\hsc_ptr -> peekByteOff hsc_ptr 112)) p
{-# LINE 122 "GHC/Stats.hsc" #-}
gcWallSeconds <- ((\hsc_ptr -> peekByteOff hsc_ptr 120)) p
{-# LINE 123 "GHC/Stats.hsc" #-}
cpuSeconds <- ((\hsc_ptr -> peekByteOff hsc_ptr 128)) p
{-# LINE 124 "GHC/Stats.hsc" #-}
wallSeconds <- ((\hsc_ptr -> peekByteOff hsc_ptr 136)) p
{-# LINE 125 "GHC/Stats.hsc" #-}
parTotBytesCopied <- ((\hsc_ptr -> peekByteOff hsc_ptr 80)) p
{-# LINE 126 "GHC/Stats.hsc" #-}
parMaxBytesCopied <- ((\hsc_ptr -> peekByteOff hsc_ptr 88)) p
{-# LINE 127 "GHC/Stats.hsc" #-}
return GCStats { .. }