[R] strange slowness of plot
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Wed Jul 25 08:52:58 CEST 2001
On Tue, 24 Jul 2001, Duncan Murdoch wrote:
> On Tue, 24 Jul 2001 14:37:48 -0500, you wrote:
> >I just ran into this strange behavior.
> > y <- rnorm(1000)
> > x <- seq(0, length=length(y))
> > plot(x, y, type='l', lty=1) - instantaneous
> > plot(x, y, type='l', lty=2) - 18s plotting lines + 15s plotting axes
> >= 33s
> ... and even longer times for other line types.
> I tried this code on my tiny little Libretto (Pentium 120Mhz, 32Mb
> ram, 20gb drive) running Win95, and it was noticeably slower doing the
> line types other than type 1, but not nearly as slow as described.
> I'd suggest you're short of some sort of graphics resource, or there's
> a Win2K bug here.
I tried Windows 2000 and it is slo....ow. If you time the function with
system.time (on NT/2000) you will see that 99+% of the time is system time.
And some checking shows that it is all being spent in the call to
StrokePath. In other words, the slowness is in the Windows 2000 GDI and
not in R. As Duncan points out, Windows 9x/ME has a different (mainly
16-bit) GDI and behaves differently (I tried Windows 98: 0.54 vs 0.09
secs as reported by system.time).
The issue is too the number of dashes needed. Drawing a sensible dashed
curve on 1000 points (say around a circle) is not slow. It looks like the
Windows 2000 GDI is very slow when asked to stroke many dashes: doubling
the number seems to take ca 7x longer. This might be dependent on the
graphics card driver, as well as on the Windows version.
Also, it does not take 15secs to plot the axes. What actually happens is
that the plot is done twice, first on screen then on a bitmap (for later
copying to a bitmap device?). That suggests that the GDI per se is to
I need to talk to Guido, but it looks as if breaking the draw up into
smaller pieces will solve this. On the other hand, it must have been there
for a couple of years, and no one has reported problems on a real plot yet.
> >My system is as follows:
> >(1) IBM Intellistation with PIII 1GHz, 512Mb of RDRAM, 20Gb SCSI160 drive,
> >64Mb FireGL graphics card
> >(2) Windows 2000 Pro
> >(3) R-1.3.0 (original version)
> Duncan Murdoch
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
Brian D. Ripley, ripley at 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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help