[R] Displaying RProf output

From: hadley wickham <h.wickham_at_gmail.com>
Date: Mon 05 Sep 2005 - 03:05:23 EST


Hi,

I've been experimenting with a new way of displaying the output from RProf, to make it easier to optimise your functions. I've included an example below. I'd love to get your feedback on how easy you think this graphic is to read, and on ways that it could be improved.

install.packages("butler")
library(butler)

# profile the glm example

profile_glm <- stopwatch(function() example(glm))

# Plot the profile
# y-axis gives percent of time spent in that function
# x-axis gives position in call stack

plot(profile_glm)

# The first few levels aren't of interest, so we can skip them:
# (see ?plot.call.tree for all options)
plot(profile_glm, startlevel=4)

# We might also want to see what's going further down
plot(profile_glm, startlevel=4, depth=10)

# By default only functions that take longer than 2% of the
# total time are shown, setting mintime changes that
plot(profile_glm, startlevel=4, depth=10, mintime=1)

One interesting thing you can see from this example is that almost 30% of the total time is just spent printing the output - why is it so slow? Well, it looks like print.summary.glm calculates a lot of the summary statistics.

Thanks,

Hadley



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Sep 05 03:18:49 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 16:18:46 EST