Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profvis doesn't draw anything #15

Closed
helske opened this issue Nov 18, 2015 · 9 comments
Closed

profvis doesn't draw anything #15

helske opened this issue Nov 18, 2015 · 9 comments

Comments

@helske
Copy link

helske commented Nov 18, 2015

I am trying to profile complex optimization problem with profvis but when trying to print the output the browser renders the output as blank screen. Same thing with Rstudio's editor.

I managed to reproduce the problem with this simple code:

rm(list = ls())
set.seed(1)
x <- rnorm(10000)

outer_function_with_obj <- function(x){
  obj1 <- function(x) {
    x1 <- x[1]
    x2 <- x[2]
    100 * (x2 - x1 * x1)^2 + (1 - x1)^2
  }
  optim(par = x, fn = obj1)
}
does_not_work <- profvis({
  outer_function_with_obj(x = x)
})

obj2 <- function(x) {
  x1 <- x[1]
  x2 <- x[2]
  100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
outer_function_without_obj <- function(x){
  optim(par = x, fn = obj2)
}
does_work <- profvis({
  outer_function_without_obj(x = x)
})
@wch
Copy link
Member

wch commented Nov 18, 2015

Hm, it looks like it happens when a function is defined and called within another function, and that outer function is defined outside of a profvis() call. (Moving it inside the profvis() makes it work.) For example, this has the same problem:

f1 <- function() {
  g <- function() {
    pause(0.1)
  }
  g()
}
profvis({
  f1()
})

But these work:

# No inner function
f2 <- function() {
  pause(0.1)
}
profvis({
  f2()
})

# Inner function is returned, then called from inside profvis()
f3 <- function() {
  g <- function() {
    pause(0.1)
  }
  g
}
profvis({
  x <- f3()
  x()
})


# Outer function is defined within profvis()
profvis({
  f4 <- function() {
    g <- function() {
      pause(0.1)
    }
    g()
  }
  f4()
})

@nuno-agostinho
Copy link

👍 I'm also having this problem.

@wch
Copy link
Member

wch commented Jan 18, 2016

I have a feeling that it won't be possible to fix this -- the R profiler output simply doesn't contain enough information to retrieve the source code that's outside of the profvis() call. So you may just have to put all your code in profvis(), or in a file that's sourced.

@wch wch closed this as completed in acd9d3b Feb 2, 2016
@wch
Copy link
Member

wch commented Feb 2, 2016

This is fixed now - it simply won't try to display code that's outside of the profvis({}) call.

Simplified test app for future reference:

library(profvis)
f <- function() {
  # This empty line is needed
  pause(0.1)
}

profvis({ f() })

@xshi0001
Copy link

xshi0001 commented Apr 1, 2018

HI! wch, I think it's not the package problem, it's something related to Rstudio. I use your code,

library(profvis)
f <- function() {
    # This empty line is needed
    pause(0.1)
}

profvis({ f() })

but the result of the profile screen is nothing
image
image

@wch
Copy link
Member

wch commented Apr 3, 2018

@xshi0001 Can you file a new issue? And please include the output of devtools::session_info().

@hwpvdtoorn
Copy link

Hi, I know this is closed, but I experienced the same thing. Since this is the only place that pops up on Google, I'd like to add, that profvis gives a blank screen when your path contains spaces.

@wch
Copy link
Member

wch commented Aug 26, 2019

@hwpvdtoorn Thanks for the report. Can you file a new issue for this? And in that issue, can you tell us which path has spaces -- for example, is it the temporary directory?

@hwpvdtoorn
Copy link

Hi, thanks for your reply. I tried to create an example but unfortunately that worked normally, so I can't repeat this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants