一些基准小测试

Gambas 是一种解释性语言,在 3.2 版本之前根本没有JIT 编译或其他方式编译为本机代码。

这里有一些主要从互联网上窃取的小基准测试,用于比较 Gambas、 JIT 编译的Gambas和解释型 Python 和 Perl 。

这些测试是在我自己的计算机上通过使用time系统实用程序运行来完成的。执行时间是用户时间和系统时间之和。 请注意,编译所有语言的源文件需要花费一点时间。

几乎所有基准测试都是笨拙的,两次连续运行之间的绝对结果可能会有所不同。

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 01 Oct. 2023).

Benchmark Python Perl Java Gambas Java JIT Gambas JIT Gambas JIT without compilation time
mandelbrot 2,46  2,32  7,99  1,39  1,41  0,16  0,06 
nbody 1,94  2,73  2,16  1,66  1,05  0,44  0,20 
polynom 5,45  10,28  3,89  3,73  1,11  0,21  0,14 
primes 4,10  5,61  3,91  1,68  1,40  0,50  0,38 
sort 1,87  3,91  2,57  1,37  1,03  0,51  0,04 
string 6,26  1,44  0,76  6,16  0,83  0,76 
string2 2,50  1,36  1,37  1,18  1,12 

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
...