Module Debug.Profile

Simple profiling library with operations to access run-time data.

Author: Michael Hanus

Version: January 2019

Summary of exported operations:

getProcessInfos :: IO [(ProcessInfo,Int)]   
Returns various informations about the current state of the Curry process.
garbageCollectorOff :: IO ()   
Turns off the garbage collector of the run-time system (if possible).
garbageCollectorOn :: IO ()   
Turns on the garbage collector of the run-time system (if possible).
garbageCollect :: IO ()   
Invoke the garbage collector (if possible).
showMemInfo :: [(ProcessInfo,Int)] -> String   
Get a human readable version of the memory situation from the process infos.
printMemInfo :: IO ()   
Print a human readable version of the current memory situation of the Curry process.
profileTime :: IO a -> IO a   
Print the time needed to execute a given IO action.
getTimings :: IO a -> IO (a,Int,Int,Int)   
Returns the run time, elapsed time, and number of garbage collections needed to execute a given IO action.
profileTimeNF :: a -> IO ()   
Evaluates the argument to normal form and print the time needed for this evaluation.
getTimingsNF :: a -> IO (Int,Int,Int)   
Evaluates the argument to normal form and returns the run time, elapsed time, and number of garbage collections needed for this evaluation.
profileSpace :: IO a -> IO a   
Print the time and space needed to execute a given IO action.
profileSpaceNF :: a -> IO ()   
Evaluates the argument to normal form and print the time and space needed for this evaluation.

Exported datatypes:


ProcessInfo

The data type for representing information about the state of a Curry process.

Constructors:

  • RunTime :: ProcessInfo : the run time in milliseconds
  • ElapsedTime :: ProcessInfo : the elapsed time in milliseconds
  • Memory :: ProcessInfo : the total memory in bytes
  • Code :: ProcessInfo : the size of the code area in bytes
  • Stack :: ProcessInfo : the size of the local stack for recursive functions in bytes
  • Heap :: ProcessInfo : the size of the heap to store term structures in bytes
  • Choices :: ProcessInfo : the size of the choicepoint stack
  • GarbageCollections :: ProcessInfo : the number of garbage collections performed

Exported operations:

getProcessInfos :: IO [(ProcessInfo,Int)]   

Returns various informations about the current state of the Curry process. Note that the returned values are implementation dependent so that one should interpret them with care!

Note for KiCS2 users: Since GHC version 7.x, one has to set the run-time option -T when this operation is used. This can be done by the kics2 command

:set rts -T
Further infos:
  • externally defined

garbageCollectorOff :: IO ()   

Turns off the garbage collector of the run-time system (if possible). This could be useful to get more precise data of memory usage.

Further infos:
  • externally defined

garbageCollectorOn :: IO ()   

Turns on the garbage collector of the run-time system (if possible).

Further infos:
  • externally defined

garbageCollect :: IO ()   

Invoke the garbage collector (if possible). This could be useful before run-time critical operations.

Further infos:
  • externally defined

showMemInfo :: [(ProcessInfo,Int)] -> String   

Get a human readable version of the memory situation from the process infos.

printMemInfo :: IO ()   

Print a human readable version of the current memory situation of the Curry process.

profileTime :: IO a -> IO a   

Print the time needed to execute a given IO action.

getTimings :: IO a -> IO (a,Int,Int,Int)   

Returns the run time, elapsed time, and number of garbage collections needed to execute a given IO action.

profileTimeNF :: a -> IO ()   

Evaluates the argument to normal form and print the time needed for this evaluation.

getTimingsNF :: a -> IO (Int,Int,Int)   

Evaluates the argument to normal form and returns the run time, elapsed time, and number of garbage collections needed for this evaluation.

profileSpace :: IO a -> IO a   

Print the time and space needed to execute a given IO action. During the executation, the garbage collector is turned off to get the total space usage.

profileSpaceNF :: a -> IO ()   

Evaluates the argument to normal form and print the time and space needed for this evaluation. During the evaluation, the garbage collector is turned off to get the total space usage.