README.md

An example Rcpp Plugin Package

This is only an example of ad-hoc sourceCpp usage.

Todo:

Dependency:

Google Performance Tools aka gperftools

sudo apt-get -y install google-perftools libgoogle-perftools-dev

Installation:

Using devtools:

devtools::install_github("thell/PluginGperf")

Usage:

Add PluginGperf to your cpp files plugins attributes...

\\ [Rcpp::plugins(PluginGperf)]

Do the plugin registration: (see Rcpp PR #409 that eliminates this requirement)

PluginGperf::register.plugin()

Source your file:

file <- system.file("examples/gperf-test.cpp", package = "PluginGperf")
Rcpp::sourceCpp(file)

Sample output:

Execute profiling function then in a shell run:
 google-pprof --web /tmp/RtmphOaX5C/sourcecpp_2d2c1fa052f1/sourceCpp_2.so gprof.out

Execute profiling function (we need a big number and want to hide the output):

invisible(gperf(1:6000000))

Sample output:

PROFILE: interrupts/evictions/bytes = 4/0/720

You can now see the gprof.out file in the working directory and can issue a google-pprof command on it using the library file in the RtmpXXX path.



Thell/PluginGperf documentation built on May 9, 2019, 4:27 p.m.