r-lib / R6

Encapsulated object-oriented programming for R
https://R6.r-lib.org
Other
407 stars 56 forks source link

Profiling R6 classes is next to impossible as the methods are anonymous #71

Closed JohnReid closed 8 years ago

JohnReid commented 9 years ago

For more details see http://stackoverflow.com/questions/31984006/how-to-profile-r6-class-functions

wch commented 8 years ago

Check out profvis for a tool that can be used to profile R6 methods. Methods will still show up as <Anonymous>, but you should be able to identify them from other information provided by profvis. In order for the methods to not show as <Anonymous>, you could save them in a temporary variable and then invoke that (as in foo <- self$foo; foo()). If you don't want to do that kind of workaround, the R profiler itself would have to provide more information. This may happen in the future, but it's not something that can be addressed from the R6 package.

wch commented 8 years ago

If you're using a recent version of R-devel (since this commit), it will output obj$fn instead of <Anonymous> in the profiling data. This should be in the next release of R (3.3.0?).

JohnReid commented 8 years ago

Great thanks, I'll check this out.