-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
63 lines (46 loc) · 2.03 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
---
output: downlit::readme_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
pkgload::load_all()
```
# profile
<!-- badges: start -->
[![rcc](https://github.com/r-prof/profile/workflows/rcc/badge.svg)](https://github.com/r-prof/profile/actions)
[![Codecov test coverage](https://codecov.io/gh/r-prof/profile/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-prof/profile?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/profile)](https://cran.r-project.org/package=profile)
<!-- badges: end -->
The goal of profile is to read and write files that contain run time profiling data. Currently, *profile* supports:
- Files created by [`Rprof()`](https://www.rdocumentation.org/packages/utils/versions/3.4.3/topics/Rprof)
- `.proto` files written by [`pprof -proto`](https://github.com/google/pprof), these can also be read by `pprof`
The data is available to the user for inspection and manipulation in a [documented stable data format](https://r-prof.github.io/profile/reference/validate_profile.html).
## Installation
You can install profile from GitHub with:
```{r gh-installation, eval = FALSE}
# install.packages("remotes")
remotes::install_github("r-prof/profile")
```
## Example
This simple example converts an `.out` file generated by `Rprof()` to the `.proto` format understood by `pprof`.
```{r example}
rprof_path <- tempfile("profile", fileext = ".out")
Rprof(rprof_path, line.profiling = TRUE)
x <- runif(1e6)
res <- vapply(x, function(x) if (x < 0.5) sqrt(x) else x * x, numeric(1))
Rprof(NULL)
library(profile)
ds <- read_rprof(rprof_path)
ds
names(ds)
write_pprof(ds, file.path(tempdir(), "1.pb.gz"))
```
---
## Code of Conduct
Please note that the profile project is released with a [Contributor Code of Conduct](https://r-prof.github.io/profile/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.