On Fri, 30 Apr 2010, Daniel Murphy wrote:

Hello:

I have written some an elementary S4 classes around a matrix to strengthen
control of some key attributes. When I run a fairly elementary function
("f") on the matrix outside the class it runs instantaneously (elapsed
system.time = 0) but when I setMethod "f" on myClass -- returning an
instance of myClass -- it runs perceptibly slower (elapsed system.time =
.06). I suspect my initialization and/or validity functions are
inefficiently written. I thought I read in this list of a function that will
trace the execution time of each of the functions called during the
evaluation of an R expression, but now I can't find that message. Is there
such a function, or was I mistaken?

Maybe Rprof? That is certainly the tool I would use, and it is described in 'Writing R Extensions'.

But we do know that S4 methods do have a significant overhead: OTOH there is caching going on and so a lot of this overhead is on first use. So you may find that your 'toy' test does not scale to a real problem (surely you have difficulty perceiving 60ms, literally the blink of an eye?).


Thank you.

Dan Murphy

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to