Skip to content

Commit

Permalink
Release v0.3.6 (#108)
Browse files Browse the repository at this point in the history
* test more R flavors

* bump version to 0.3.6

* Use revdep

* encoding utf-8 for roxygen2

* make docs/

* missing namespace

* spelling

* setup release scripts

* Update cran-comments.md

* run revdep one last time

* bump htmlwidget version

* removed extra bullet
  • Loading branch information
schloerke committed May 15, 2019
1 parent 2fe2649 commit ea28f67
Show file tree
Hide file tree
Showing 57 changed files with 6,660 additions and 3,983 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
^\.travis\.yml$
^CONTRIBUTING.md$
^docs$
^revdep$
^cran-comments\.md$
^scripts$
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ language: r
sudo: false
cache: packages

r:
- oldrel
- release
- devel

notifications:
email:
on_success: change
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: profvis
Title: Interactive Visualizations for Profiling R Code
Version: 0.3.5.9000
Version: 0.3.6
Authors@R: c(
person("Winston", "Chang", email = "winston@rstudio.com", role = c("aut", "cre")),
person("Javier", "Luraschi", email = "javier@rstudio.com", role = "aut"),
Expand Down Expand Up @@ -29,3 +29,4 @@ Suggests:
htmltools
RoxygenNote: 6.1.1
URL: https://rstudio.github.io/profvis/
Encoding: UTF-8
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
profvis 0.3.5.9000
profvis 0.3.6
=============

* Added a profvis Shiny module, for starting/stopping the profiler during the execution of a Shiny application. This can be helpful if you don't want to profile the entire execution of an app, only a certain operation. To install the profvis module into your app, add `profvis_ui("profvis")` to your UI, and `callModule(profvis_server, "profvis")` to your server function.
Expand All @@ -8,7 +8,7 @@ profvis 0.3.5.9000
profvis 0.3.5
=============

* Fixed problem with development build of R where source refs are turned on by defaut (reported by Tomas Kalibera).
* Fixed problem with development build of R where source refs are turned on by default (reported by Tomas Kalibera).

profvis 0.3.4
=============
Expand Down
2 changes: 1 addition & 1 deletion R/profvis.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' sampling profiler and garbage collection: when garbage collection triggers,
#' memory allocations will be attributed to different lines of code. Using
#' \code{torture = steps} helps prevent this, by making R trigger garbage
#' collection afer every \code{torture} memory allocation step.
#' collection after every \code{torture} memory allocation step.
#'
#' @seealso \code{\link{print.profvis}} for printing options.
#' @seealso \code{\link{Rprof}} for more information about how the profiling
Expand Down
2 changes: 1 addition & 1 deletion R/shiny_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ profvis_ui <- function(id) {
)

shiny::tagList(
tags$style(
htmltools::tags$style(
".profvis-module-container:empty() { visibility: hidden; }"
),
shiny::fixedPanel(
Expand Down
37 changes: 37 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Comments

### May 14, 2019

Submitting small enhancements. Please let me know if there is anything I can do.

Thank you for your time,
- Winston


## Test environments
* local OS X install, R 3.6.0
* travis-ci ubuntu 14.04
* R 3.5.3
* R 3.6.0
* R Under development (unstable) (2019-05-13 r76492)
* win-builder (devel and release)
* R version 3.5.3 (2019-03-11)
* R version 3.6.0 (2019-04-26)
* R Under development (unstable) (2019-05-12 r76489)
* rhub
* Windows Server 2008 R2 SP1, R-devel, 32/64 bit
* Ubuntu Linux 16.04 LTS, R-release, GCC
* Fedora Linux, R-devel, clang, gfortran
* Debian Linux, R-devel, GCC ASAN/UBSAN

## R CMD check results

0 errors | 0 warnings | 0 notes


## revdepcheck results

We checked 3 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages
26 changes: 13 additions & 13 deletions docs/examples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Examples"
output:
html_document:
toc: true
editor_options:
editor_options:
chunk_output_type: console
---

Expand Down Expand Up @@ -34,7 +34,7 @@ Below are some examples of profvis in use. Keep in mind that R's sampling profil

In this first example, we'll work with a data frame that has 151 columns. One of the columns contains an ID, and the other 150 columns contain numeric values. What we will do is, for each numeric column, take the mean and subtract it from the column, so that the new mean value of the column is zero.

```{r}
```{r ex1}
# Generate data
times <- 4e5
cols <- 150
Expand All @@ -60,9 +60,9 @@ Looking at the flame graph, we can see that `apply` calls `as.matrix` and `aperm

We could try to speed this up in a number of ways. One possibility is that we could simply leave the data in matrix form (instead of putting it in a data frame in line 4). That would remove the need for the `as.matrix` call, but it would still require `aperm` to transpose the data. It would also lose the connection of each row to the `id` column, which is undesirable. In any case, using `apply` over columns looks like it will be expensive because of the call to `aperm`.

An obvious alternative is to use the `colMeans` function. But there's also another possibility. Data frames are implemented as lists of vectors, where each column is one vector, so we could use `lapply` or `vapply` to apply the `mean` function over each column. Let's compare the speed of these four different ways of getting column means.
An obvious alternative is to use the `colMeans` function. But there's also another possibility. Data frames are implemented as lists of vectors, where each column is one vector, so we could use `lapply` or `vapply` to apply the `mean` function over each column. Let's compare the speed of these four different ways of getting column means.

```{r}
```{r ex1_apply}
profvis({
data1 <- data
# Four different ways of getting column means
Expand All @@ -81,7 +81,7 @@ You can also see that the faster methods also result in less memory allocation a

Let's take the original code and replace `apply` with `vapply`:

```{r}
```{r ex1_for}
profvis({
data1 <- data
means <- vapply(data1[, names(data1) != "id"], mean, numeric(1))
Expand All @@ -96,7 +96,7 @@ Our code is about 3x faster than the original version. Most of the time is now s

In this case, it's useful to take a step back and think about the broader problem. We want to normalize each column. Couldn't we we apply a function over the columns that does both steps, taking the mean and subtracting it? Because a data frame is a list, and we want to assign a list of values into the data frame, we'll need to use `lapply`.

```{r}
```{r ex1_norm}
profvis({
data1 <- data
Expand All @@ -121,7 +121,7 @@ This example addresses some more advanced issues. This time, it will be hard to

Suppose you have a data frame that contains a column for which you'd like to take a cumulative sum (and you don't know about R's built-in `cumsum` function). Here's one way to do it:

```{r}
```{r ex2}
profvis({
data <- data.frame(value = runif(5e4))
Expand Down Expand Up @@ -151,7 +151,7 @@ Finally, many of the flame graph cells contain the entire expression from line 6

This profiling data tells us that much of the time is spent in `$` and `$<-`. Maybe avoiding these functions entirely will speed things up. To do that, instead of operating on data frame columns, we can operate on temporary vectors. As it turns out, writing a function that takes a vector as input and returns a vector as output is not only convenient; it provides a natural way of creating temporary variables so that we can avoid calling `$` and `$<-` in a loop.

```{r}
```{r ex2_csum}
profvis({
csum <- function(x) {
if (length(x) < 2) return(x)
Expand All @@ -166,7 +166,7 @@ profvis({
})
```

Using this `csum` function, it takes about 20 ms, which is about 600x as fast as before.
Using this `csum` function, it takes about 20 ms, which is about 600x as fast as before.

It may appear that no functions are called from line 7, but that's not quite true: that line also calls `[`, `[<-`, `-`, and `+`.

Expand All @@ -179,7 +179,7 @@ In the `csum` function, `sum` starts as a length-1 vector, and then grows, in a

To avoid all that memory allocation, copying, and garbage collection, we can pre-allocate a correctly-sized vector for `sum`. For this data, that will result in 49,999 fewer allocations, copies, and deallocations.

```{r}
```{r ex2_csum2}
profvis({
csum2 <- function(x) {
if (length(x) < 2) return(x)
Expand All @@ -202,7 +202,7 @@ This version of the code, with `csum2`, is around 60x faster than our original c

In addition to R code, you can also profile [Shiny](http://shiny.rstudio.com) applications. To do this, simply execute the `runApp()` command inside of `profvis`. For instance, we can run one of shiny's built-in examples using the `runExample` command (which is a wrapper for `runApp`).

```{r,eval=FALSE, echo=FALSE}
```{r ex3,eval=FALSE, echo=FALSE}
#This code block is what we run, it must be manually run each time
library(shiny)
p<-profvis({
Expand All @@ -213,7 +213,7 @@ saveRDS(p, "shinyapp.rds")
```


```{r,eval=FALSE}
```{r ex3_tabsets,eval=FALSE}
library(shiny)
profvis({
runExample(example = "06_tabsets", display.mode = "normal")
Expand All @@ -225,7 +225,7 @@ Your Shiny application will launch, and after interacting and closing the app a

![](profvis-shiny-demo.gif)

```{r,echo=FALSE}
```{r ex3_readRDS,echo=FALSE}
# This block loads the data from the first block and shows the correct output
# for the readers.
readRDS("shinyapp.rds")
Expand Down
Loading

0 comments on commit ea28f67

Please sign in to comment.