This page is no longer maintained — Please continue to the home page at www.scala-lang.org

delay in running a script

2 replies
Russ P.
Joined: 2009-01-31,
User offline. Last seen 1 year 26 weeks ago.
I am still learning Scala, and I am using #! scripts to get started. I am finding that I need to wait something like 20 to 30 seconds every time I run a short script. That gets a bit wasteful of my time when I am running them over and over.

My experience with Python is that a script starts running almost immediately. Is there a way to speed up the running of scripts in Scala? fsc perhaps? Thanks.

Russ P.

http://RussP.us
mailleux
Joined: 2008-08-23,
User offline. Last seen 4 years 7 weeks ago.
Re: delay in running a script


On Wed, Mar 4, 2009 at 7:24 PM, Russ Paielli <russ.paielli@gmail.com> wrote:
I am still learning Scala, and I am using #! scripts to get started. I am finding that I need to wait something like 20 to 30 seconds every time I run a short script. That gets a bit wasteful of my time when I am running them over and over.

My experience with Python is that a script starts running almost immediately. Is there a way to speed up the running of scripts in Scala? fsc perhaps? Thanks.

Scala runs on a Java Runtime Environment. My experience is that stating JRE can taken a while, depending on the machine time looks possible. I believe Python has a lighter runtime.

On my machine the first run takes 10 seconds, then it drops to 4-3 seconds, but I've seen long time on other machines.

$ time scala/scala-2.7.2.final/bin/scala -e "exit"

real    0m10.820s
user    0m0.410s
sys     0m0.213s

$ java -version
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

Maybe different JRE can have different results.

Thomas
Mark Harrah
Joined: 2008-12-18,
User offline. Last seen 35 weeks 3 days ago.
Re: delay in running a script

On Friday 06 March 2009, Thomas Sant Ana wrote:
> On Wed, Mar 4, 2009 at 7:24 PM, Russ Paielli wrote:
> > I am still learning Scala, and I am using #! scripts to get started. I am
> > finding that I need to wait something like 20 to 30 seconds every time I
> > run a short script. That gets a bit wasteful of my time when I am running
> > them over and over.
> >
> > My experience with Python is that a script starts running almost
> > immediately. Is there a way to speed up the running of scripts in Scala?
> > fsc perhaps? Thanks.
>
> Scala runs on a Java Runtime Environment. My experience is that stating JRE
> can taken a while, depending on the machine time looks possible. I believe
> Python has a lighter runtime.
>
>
> On my machine the first run takes 10 seconds, then it drops to 4-3 seconds,
> but I've seen long time on other machines.
>
> $ time scala/scala-2.7.2.final/bin/scala -e "exit"
>
> real 0m10.820s
> user 0m0.410s
> sys 0m0.213s
>
> $ java -version
> java version "1.6.0_11"
> Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
> Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
>
> Maybe different JRE can have different results.

The above command starts up fsc and compiles "exit" before running it. The
jvm itself starts up very quickly- it is the compiler startup and execution
that takes time. If you run the command twice, it will be faster the second
time because fsc is already running. Run 'fsc -shutdown' and it will be
closer to the first time again.

Also, when running scripts, passing the -savecompiled option to scala will
probably help when the script hasn't changed.

-Mark

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland