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

How to run profvis so it show runtime for each line of a function from a package without rewriting the function as input? #145

Closed
garyzhubc opened this issue Oct 5, 2023 · 1 comment

Comments

@garyzhubc
Copy link

garyzhubc commented Oct 5, 2023

Right now it seems like profvis requires re-writing the function

profvis({fun<-function(...) { ... return(...) } })

But if we only pass the function evaluation to profvis it will compress the whole function into one line

profvis(fun(...))

Is there a way to profile the function line by line without re-writing the whole script as input?

@wch
Copy link
Member

wch commented Oct 5, 2023

Yes. The code needs to be sourced with source refs. If your are using source("file.R") in an interactive session, it should be loaded with source refs.

If the function is in a package, see this for information on how to load it with source refs: https://rstudio.github.io/profvis/faq.html#how-do-i-get-code-from-an-r-package-to-show-in-the-code-panel

@hadley hadley closed this as completed Jul 2, 2024
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

3 participants