linux-perf-0.3: Read files generated by perf on Linux

Safe HaskellNone




A higher-level interface to the perf data file parsing code.

Below is an example program which reads and parses a file and then dumps the contents to standard output:

module Main where

import Profiling.Linux.Perf (readAndDisplay, OutputStyle (..))
import System.Environment (getArgs)

main :: IO ()
main = do
  args <- getArgs
  case args of
     [] -> return ()
     (file:_) -> readAndDisplay Dump file


Data types

type TypeMap = Map EventID TypeInfoSource

Associate events with their event types. Events are (usually) tagged with an EventID. Many events can share the same EventID. Each EventID is associated with exactly one event type, which includes the name of the event, an EventSource and an EventTypeID

data TypeInfo Source

Type information for of event.




typeInfo_name :: String

Printable name of the event source.

typeInfo_source :: EventSource

Kind of the event source (hardware, software, tracepoint etc.).

typeInfo_id :: EventTypeID

Unique number of this type of event.

data OutputStyle Source

Style to use for printing the event data.



Output full details of the data file preserving the original order of the events.


Output command and sample events in time order with event type annotations.


readAndDisplay :: OutputStyle -> FilePath -> IO ()Source

Read the contents of the file and render it on stdout in a specified style.

readPerfData :: FilePath -> IO PerfDataSource

Read and parse the file into its constituent components.

display :: OutputStyle -> PerfData -> IO ()Source

Render the components of the file under the specified style. Don't create a single big Doc or String to avoid stack overflows. Instead, lazily print events as they are rendered.

makeTypeMap :: PerfData -> TypeMapSource

Build a map from EventIDs to their type information.

sortEventsOnTime :: [Event] -> [Event]Source

Sort a list of events in ascending time order. Events without a timestamp are treated as having a timestamp of 0, which places them at the start of the sorted output.