Complete.Org: Mailing Lists: Archives: freeciv-dev: September 1999:
Re: Guile and speed (Re: [Freeciv-Dev] Adding scripting language)
Home

Re: Guile and speed (Re: [Freeciv-Dev] Adding scripting language)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv Dev <freeciv-dev@xxxxxxxxxxxx>
Subject: Re: Guile and speed (Re: [Freeciv-Dev] Adding scripting language)
From: Artur Biesiadowski <abies@xxxxxxxxx>
Date: Fri, 03 Sep 1999 14:03:49 +0200

Lalo Martins wrote:

> Actually Guile is very good at that; it's awfully slow (at least
> with the version people have today) to _load_ code, and to start
> itself, but once code is `memoized' it runs as fast as any
> partially compiled stuff - like perl or python, and faster than
> java in my experience.

I'm not sure for what types of programs have you used these languages,
but my experiences are totally different. As all these languages'
strengths lies in different areas, I have to decide on some area - I've
chosen one that none of them is designed for - number crunching.

Attached are sources for java and guile. I don't know if I haven't made
any major performance mistake in guile - if so then please correct me,
I'll rerun the tests.

Test is very simple - in fact it could be solved at compile time. I
thought that guile will show it's power here - smart inlining is one of
functional languages domains. I've done same program in perl and in C
for comparison. Here are the results (measured with time - so overhead
of loading is included, but I don't think it is important; also
computation starts with small value (1000) to give everybody chance to
optimize function)

C          9,7s
java      26,0s
perl   ~3270,0s (give up after 5th step, which gave 30s, so it is about
109x as much..)
guile ~12200,0s (give up after 5th step, with 112 s)

Before somebody will jump on me that guile isn't fortran, JAVA IS
NEITHER, NOR PERL. I'm sure that scheme/guile has programming constructs
that make coding easier/faster maybe even more readable(I doubt this
one:), but it is slow as a dog. 500x slower than java on simple algo -
I'm afraid to think about more complicated things...

I've used guile checked out from CVS few days ago. If there is some
runtime switch to make it run 600x faster please tell me - guile --help
had not listed it.

Artur

P.S.
If somebody is interested I can send perl/C code, but it is
straigforward java translation.

Attachment: Test.java
Description: application/unknown-content-type-jbuilder.java

(define (x c)
 
 (do (
      (cc c (1- cc)) 
      (d 0 (if (zero?  (modulo cc 2))
               (+ d cc)
               (- d cc)
           )
      )
     ) 
     ((> 0 cc) d) 
     ( ) 
 )
  
)


(write ( x 1000 ))
(newline)
(write( x 10000 ))
(newline)
(write( x 100000 ))
(newline)
(write( x 1000000 ))
(newline)
(write( x 10000000 ))
(quit)
(newline)
(write( x 100000000 ))
(newline)
(write( x 1000000000 ))
(newline)

[Prev in Thread] Current Thread [Next in Thread]