0

I'm profiling my R code time and memory consumption using lineprof. This gives good results for explicit commands I write, however when i use external packages it doesn't give the required information. For example, i try running the following (using igraph):

library(igraph)
communityCalc <- function(n, p) {
   graph <- erdos.renyi.game(n, p, directed = FALSE, loops = FALSE)
   community <- leading.eigenvector.community(graph)
}
memoryProfile <- lineprof(communityCalc(n=10000, p=0.0014))
shine(memoryProfile)

The results I get for memory is that even though creating the graph takes up much memory, the community calculation doesn't. The reason is that "community" is a small data structure. I would like to somehow get the amount of memory allocated by "leading.eigenvector.community" function, and not just the output. If possible i would like deeper resolution showing even results within the function.

user3370773
  • 435
  • 6
  • 11
  • Not sure if this would solve the problem, but note that line numbers will only be available if you install the package with "keep source = TRUE". – Joshua Ulrich Jan 13 '15 at 13:10
  • That function is implemented in C, so you'll need a C level debugger for it. E.g. if you use OS X, then you can use Instruments, which is now built into Xcode. – Gabor Csardi Jan 13 '15 at 14:16
  • Thanks for the reply. Could you please elaborate more on how to use Xcode, or any other C level debugger? I'm using Windows8 OS. – user3370773 Jan 13 '15 at 16:27
  • I should have said profiler rather. Xcode is for OS X only. I guess there is a similar tool for windows. E.g. http://stackoverflow.com/questions/67554/whats-the-best-free-c-profiler-for-windows – Gabor Csardi Jan 13 '15 at 21:56

0 Answers0