-
Notifications
You must be signed in to change notification settings - Fork 6
/
README.Rmd
129 lines (92 loc) · 3.16 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
output:
github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# jointprof
[![Travis build status](https://travis-ci.org/r-prof/jointprof.svg?branch=master)](https://travis-ci.org/r-prof/jointprof) [![Coverage status](https://codecov.io/gh/r-prof/jointprof/branch/master/graph/badge.svg)](https://codecov.io/github/r-prof/jointprof?branch=master) [![CRAN status](http://www.r-pkg.org/badges/version/jointprof)](https://cran.r-project.org/package=jointprof)
The goal of jointprof is to assist profiling R packages that include native code (C++, C, Fortran, ...).
It collects profiling output simultaneously using [Rprof](https://www.rdocumentation.org/packages/utils/versions/3.4.3/topics/Rprof) and [gperftools](https://github.com/gperftools/gperftools) and provides a unified view of profiling data.
See the [guide](https://r-prof.github.io/jointprof/articles/guide.html) for a more detailed overview, or take a look at the [internals](https://r-prof.github.io/jointprof/articles/internals.html) document if you're curious.
## Installation
### Ubuntu
Other Linux distributions may work if you install the right system dependencies ([let me know](https://github.com/r-prof/jointprof/issues) which!).
1. Install system dependencies:
```sh
sudo apt install \
libgoogle-perftools-dev \
libprotoc-dev libprotobuf-dev protobuf-compiler \
golang-go \
graphviz
```
1. Install `pprof`:
```sh
go get github.com/google/pprof
```
1. Install the package:
```r
# install.packages("remotes")
remotes::install_github("r-prof/jointprof")
```
### OS X
1. Install system dependencies:
```sh
brew install graphviz
```
1. Install `gperftools` (currently from a branch, [pull request](https://github.com/gperftools/gperftools/pull/1004) pending):
```sh
git clone https://github.com/krlmlr/gperftools.git -b f-export-stack
cd gperftools
./autogen.sh
./configure
make
sudo make install
cd ..
```
1. Install `pprof`:
```sh
go get github.com/google/pprof
```
1. Install the package:
```r
# install.packages("remotes")
remotes::install_github("r-prof/jointprof")
```
### Other OS
Windows and Solaris are not supported.
## Usage
```r
library(jointprof)
target_file <- "Rprof.out"
# Collect profile data
start_profiler(target_file)
## code to be profiled
stop_profiler()
# Analyze profile data
summaryRprof(target_file)
profvis::profvis(prof_input = target_file)
proftools::readProfileData(target_file)
prof.tree::prof.tree(target_file)
# Convert to pprof format and analyze
pprof_target_file <- "Rprof.pb.gz"
profile_data <- profile::read_rprof(target_file)
profile::write_rprof(profile_data, pprof_target_file)
system2(
find_pprof(),
c(
"-http",
"localhost:8080",
shQuote(pprof_target_file)
)
)
```
## Acknowledgment
This project is being realized with financial support from the
<img src="https://www.r-consortium.org/wp-content/uploads/sites/13/2016/09/RConsortium_Horizontal_Pantone.png" width="400">