[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Guile 2.2.4 vs Guile 1.8
From:       Jacques Menu <imj-muzhic () bluewin ! ch>
Date:       2020-07-26 7:03:47
Message-ID: 4EF414F7-EBD7-4616-857D-76F0A2A9CA0B () bluewin ! ch
[Download RAW message or body]

Hello folks,

I've been curious about what the compilation provided by Guile 2.x leads to in terms \
of function calls speed.

Here are the results of tabulating the Ackermann function up to 'Ack (3, 10)' on my \
machine in various languages, with output like the one below.

The code for function Ack() is straightforward in all languages, no attempt is made \
to maximise speed with language-specific features. For example, in Guile and Lua:

(define (Ack m n)
  (if (= m 0)
    (+ n 1)
    (if (= n 0)
      (Ack (- m 1) 1)
      (Ack (- m 1) (Ack m (- n 1)))
    )
  )
)

function Ack (m, n)
  if (m == 0) then
    return n + 1
  else
    if (n == 0) then
      return Ack (m - 1, 1)
    else
      return Ack (m - 1, Ack (m, n - 1))
    end
  end
end

Times vary from run to run of course, but the figures give an idea.

I'd be interested in testing a small data-centric example, that would be typical of \
what LilyPond does frequently. Hints are welcome.

HTH, for what it's worth!

JM

—

C++ (clang version 11.0.0) :
  real	0m0.347s
  user	0m0.335s
  sys	0m0.010s

Swift 5.1.3 :
  real	0m0.648s
  user	0m0.544s
  sys	0m0.097s

Guile 2.2.4, compiled :
  real	0m1.184s
  user	0m1.146s
  sys	0m0.034s

Lua 5.3.5 :
  real	0m3.167s
  user	0m3.072s
  sys	0m0.082s

Guile 1.8 :
  real	0m9.460s
  user	0m8.841s
  sys	0m0.401s

Python 3.8.4 :
  real	0m14.888s
  user	0m12.111s
  sys	0m2.718s

--

menu@macbookprojm: ~/Lua/Ackermann > guile --version
guile (GNU Guile) 2.2.4
Copyright (C) 2018 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
menu@macbookprojm: ~/Lua/Ackermann > 


menu@macbookprojm: ~/Lua/Ackermann > time guile Ackermann.scm
"(Ack 1  1) =    3"
"(Ack 1  2) =    4"
"(Ack 1  3) =    5"
"(Ack 1  4) =    6"
"(Ack 1  5) =    7"
"(Ack 1  6) =    8"
"(Ack 1  7) =    9"
"(Ack 1  8) =   10"
"(Ack 1  9) =   11"
"(Ack 1 10) =   12"
"(Ack 2  1) =    5"
"(Ack 2  2) =    7"
"(Ack 2  3) =    9"
"(Ack 2  4) =   11"
"(Ack 2  5) =   13"
"(Ack 2  6) =   15"
"(Ack 2  7) =   17"
"(Ack 2  8) =   19"
"(Ack 2  9) =   21"
"(Ack 2 10) =   23"
"(Ack 3  1) =   13"
"(Ack 3  2) =   29"
"(Ack 3  3) =   61"
"(Ack 3  4) =  125"
"(Ack 3  5) =  253"
"(Ack 3  6) =  509"
"(Ack 3  7) = 1021"
"(Ack 3  8) = 2045"
"(Ack 3  9) = 4093"
"(Ack 3 10) = 8189"

real	0m1.184s
user	0m1.146s
sys	0m0.034s
menu@macbookprojm: ~/Lua/Ackermann >


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic