[Newbies] Query about Transcript object

goran at krampe.se goran at krampe.se
Tue Apr 3 07:13:11 UTC 2007


Hi!

"Ian Oversby" <oversby at googlemail.com> wrote:
> Hi Ramon,
> 
> Thanks for the answers.
> 
> On 03/04/07, Ramon Leon <ramon.leon at allresnet.com> wrote:
> > > Hi,
> > >
> > > I wrote the following line of code to display the numbers 1
> > > to 200 in the Transcript Window.
> > >
> > > 1 to: 200 do: [ :x | Transcript show: x ; cr ].
> > >
> > > The numbers are displayed quite slowly and while they are
> > > being displayed, I am unable to perform any other action, for
> > > example, click on other Windows to raise them to the front or
> > > bring up the context sensitive menu.  What am I doing wrong?
> > >
> > > Thanks,
> > >
> > > Ian
> >
> > You aren't doing anything wrong.  The Transcript is very slow, it's meant
> > for debugging, never worry about speed while printing to the transcript.
> > Never print to the transcript when you're worrying about speed.
> 
> Is there an alternative way to log information then, that isn't so slow?

The reason for Transcript to be slow is the scrolling IIRC - lots of
bitmap copying etc.
It is much faster if you close the Transcript window. On my laptop it
then runs in 175 ms instead of about 5 seconds. Do "print it" on this:

	[1 to: 200 do: [ :x | Transcript show: x ; cr ]] timeToRun

In the Gjallar project we have also developed a little logging framework
which is quite nice.
I started breaking it out of Gjallar - almost done. Also there is a
package called Toothpick - haven't used it. And I think at least one
more logging lib on SqueakMap.

> > Squeak's UI runs do its on the same thread as the UI thread, so while you
> > execute any code in a workspace, expect the whole UI to lockup.
> 
> Is there a way to run code in the background so that the UI stays available?

Sure, just fork it off. But then you might also get bitten by the fact
that Transcript is not thread safe! :)

	[1 to: 200 do: [ :x | Transcript show: x ; cr ]] fork

regards, Göran


More information about the Beginners mailing list