papi.start {pbdPAPI} | R Documentation |
Low level interface for pbdPAPI.
papi.start(events) papi.stop(events) system.event(expr, events, gcFirst = TRUE, burnin = TRUE)
events |
A vector of PAPI events (as strings). See details section for more information. |
expr |
A valid R expression to be profiled. |
gcFirst |
logical; determines if garbage collection should be called before profiling. |
burnin |
logical; determines if the function should first be evaluated with an empty expression. This can be especially important for measuring cache effects. |
This is the low-level interface for accessing hardware counters, and should look somewhat similar to PAPI's own low-level interface. This offers a great deal of control, at the expense of ease of use. If you are new to pbdPAPI and/or PAPI, it is recommended that you start with the higher level interfaces.
To use, you should first construct an events vector, which consists of a set of pre-specified strings (listed in detail below; scroll down, you can't miss it). For example, if you want to profile level 1 and level 2 data cache misses, you would set
events <- c("PAPI_L1_DCM", "PAPI_L2_DCM")
|
You would then enclose the code you wish to profile with a call to
papi.start(events)
, call that code, then call
papi.stop(events)
to end profiling.
Another version of the low-level interface is in the system.event()
function, which has syntax reminiscent of system.time()
. Using this
instead of papi.start()
and papi.stop()
in the above example,
you would instead call system.event(expr, events)
, where expr
is the valid R expression you want profiled.
The results of the requested PAPI events are returned, in a named list, with values stored in double precision.
## Not run: library(pbdPAPI) events <- c("PAPI_L1_DCM", "PAPI_L2_DCM") # Start profiling papi.start(which=events) # Computationally interesting code sum(sapply(1:100, sqrt)) # Stop profiling and collect results results <- papi.stop(which=events) results ## End(Not run)