It seems that there are speed issues when printing to the R console from a
tcl/tk GUI.

Here are functions to write a lot of output, and to display how long it
takes.

printsalot <- function(n)
{
  for(i in 1:n) cat(i, fill = TRUE)
}

timings <- function(n = 1e3)
{
  print(system.time(printsalot(n)))
}

Calling timings() from the console reveals a run time of a few hundredths
of a second.

The following GUI has two buttons.  Clicking the "slow" buttons just calls
timings directly, and takes several seconds to run.  However, if we request
input from the console, via readline (the "fast" button) then the timing
drops back down to hundredths of a second.

library(tcltk)
win <- tktoplevel()
btn1 <- ttkbutton(win, text = "slow", command = function() timings())
btn2 <- ttkbutton(win, text = "fast", command = function() {readline("Press
ENTER > "); timings()})
tkpack(btn1, btn2)

I've only observed this slow behaviour with RGui on Windows (XP) - it
doesn't happen with Rterminal or eclipse/StatET or RStudio.

I want a few people to run this code to see if it affects, for example,
other OSes, to narrow down the extent of the problem before I submit it as
a bug.

Also, if you have any insight as to what is happening or fixes, I'd be
interested to know.

Regards,
Richie.

	[[alternative HTML version deleted]]

