Benchmarks

Gambas is an interpreted language, with no "just-in-time" or other compilation to native code at all up to the 3.2 version.

Here is some little benchmarks mostly stolen on the Internet used for comparing Gambas and Gambas JIT-compiled with interpreted Python and Perl.

The tests were done on my own computer, by running them with the time system utility. The execution time is the sum of the user time and the system time.

Note there is a little time used for compiling the source files in all languages.

Almost all benchmarks are stupid, and absolute results may vary between two successive runs.

Some results

Ubuntu 23.04

Kernel and languages versions were:

  • Linux kernel 6.2.0-33-generic with AMD Ryzen 5700G CPU.

  • Python 3.11.4.

  • Perl 5.36.0.

  • Java openjdk 17.0.8.1 2023-08-24

  • Gambas 3.18.90 (development version on 04 Oct. 2023).

Benchmark Python Perl Java Gambas Java JIT Gambas JIT Gambas JIT without compilation time
btree 3,47  3,72  4,89  2,33  1,29  2,24  2,12 
mandelbrot 2,32  2,31  8,01  1,37  1,46  0,16  0,06 
nbody 1,92  2,83  2,24  1,64  1,17  0,43  0,18 
polynom 5,25  10,14  4,03  3,68  1,23  0,21  0,14 
primes 4,69  6,03  4,06  1,80  1,60  0,53  0,41 
sort 1,87  3,93  2,62  1,43  1,19  0,53  0,04 
string1 3,71  1,50  30,00+  0,92  6,60  1,07  1,00 
string2 30,00+  2,45  30,00+  1,35  1,54  1,20  1,14 

Execution times are measured in seconds.
The Python interpreter is unable to complete the string2 benchmark in less than 30 seconds.
The Java interpreter is unable to complete the string and string2 benchmarks in less than 30 seconds.

Ubuntu 22.10

Kernel and languages versions were:

  • Linux kernel 5.19.0-26-generic with AMD Ryzen 5700G CPU.

  • Python 3.10.7.

  • Perl 5.34.0.

  • Java openjdk 18.0.2-ea 2022-07-19.

  • Gambas 3.17.90 (development version on 10 Jan. 2023).

Benchmark Python Perl Java Gambas Java JIT Gambas JIT Gambas JIT without compilation time
mandelbrot 3,24  2,28  8,27  1,76  1,28  0,18  0,08 
nbody 2,97  2,65  2,32  2,25  0,98  0,44  0,19 
polynom 8,38  9,45  4,88  5,71  1,17  0,22  0,15 
primes 4,38  5,61  4,17  1,90  1,34  0,50  0,38 
sort 2,91  3,64  2,54  2,94  0,95  0,52  0,04 
string 3,39  1,35  0,75  6,07  0,86  0,79 
string2 4,57  2,48  1,48  1,23  1,22  1,15 

Execution times are measured in seconds.
The Java interpreter is unable to complete the string and string2 benchmarks in less than 30 seconds.

Ubuntu 22.04

Kernel and languages versions were:
  • Linux kernel 5.15.0-48-generic with AMD Ryzen 5700G CPU.

  • Python 3.10.6.

  • Perl 5.34.0.

  • Gambas 3.17.90 (development version on 08 Oct. 2022).

Benchmark Python Perl Gambas Gambas JIT Gambas JIT without compilation time
mandelbrot 3,13  2,29  1,81  0,16  0,07 
nbody 2,81  2,70  2,32  0,41  0,20 
polynom 7,78  9,61  5,94  0,20  0,14 
primes 4,26  5,60  1,98  0,47  0,39 
sort 2,88  3,72  3,10  0,44  0,04 
string 3,43  1,41  0,85  0,89  0,83 
string2 4,65  2,65  1,51  1,13  1,07 

Execution times are measured in seconds.

Ubuntu 21.04

Kernel and languages versions were:
  • Linux kernel 5.11.0-37-generic on Intel Core i5-3570K.

  • Python 2.7.18.

  • Perl 5.32.1.

  • Gambas 3.16.90 (development version on 20 Oct. 2021).

Benchmark Python Perl Gambas Gambas JIT Gambas JIT without compilation time
mandelbrot 5,27  3,83  2,85  0,21  0,10 
nbody 4,30  4,56  3,87  0,59  0,31 
polynom 9,69  14,38  6,65  0,53  0,45 
primes 6,90  7,78  2,59  0,67  0,55 
sort 3,54  6,32  4,43  0,65  0,07 
string 8,80  1,77  1,37  1,47  1,39 
string2 5,34  2,95  1,77  1,24  1,16 

Execution times are measured in seconds.

Ubuntu 20.04

Kernel and languages versions were:
  • Linux kernel 5.4.0-42-generic on Intel Core i5-3570K.

  • Python 2.7.18rc1.

  • Perl 5.30.0.

  • Gambas 3.15.90 (development version on 8 Feb. 2021).

Benchmark Python Perl Gambas Gambas JIT Gambas JIT without compilation time
mandelbrot 5,04  3,94  3,07  0,22  0,09 
nbody 4,18  4,57  3,71  0,68  0,28 
polynom 9,91  13,13  6,71  0,53  0,44 
primes 6,43  7,98  3,10  0,65  0,51 
sort 3,38  5,86  4,35  0,70  0,07 
string 8,77  1,72  1,41  1,48  1,39 
string2 5,44  2,94  1,91  1,42  1,34 

Execution times are measured in seconds.

Ubuntu 19.10

Kernel and languages versions were:
  • Linux kernel 5.3.0-45-generic.

  • Python 2.7.17.

  • Perl 5.28.1.

  • Gambas 3.14.90 (development version on 06 Apr. 2020).

Benchmark Python Perl Gambas Gambas JIT Gambas JIT without compilation time
mandelbrot 4,95  3,93  3,03  0,22  0,10 
nbody 4,36  4,53  4,06  0,66  0,29 
polynom 10,14  12,63  8,92  0,53  0,44 
primes 6,37  7,76  3,52  0,63  0,51 
sort 3,36  5,77  5,05  0,60  0,06 
string 9,21  2,00  1,44  1,53  1,44 
string2 5,27  2,92  1,96  1,35  1,28 

Execution times are measured in seconds.

Benchmark source code

To get the source code of the benchmarks, browse the benchmark directory in the Gambas source code.

Run the benchmark on your own system

There is a script named benchmark.gbs in the benchmark directory. Just open a terminal, change to that directory, and run it.

You will get the result as HTML data. If you want to share it, don't forget to specify which distribution you run and your CPU model.

For example, on my own system (with 8 cores, hence the repeated lines):

$ uname -a
Linux benoit-kubuntu 5.3.0-45-generic #37-Ubuntu SMP Thu Mar 26 20:41:27 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ cat /proc/cpuinfo | grep "model name"
model name      : AMD Ryzen 7 5700G with Radeon Graphics
model name      : AMD Ryzen 7 5700G with Radeon Graphics
model name      : AMD Ryzen 7 5700G with Radeon Graphics
...