1 : Are the Lua programs faster? At a glance.

Each chart bar shows, for one unidentified benchmark, how much the fastest Lua program used compared to the fastest C++ g++ program.

(Memory use is only compared for tasks that require memory to be allocated.)


These are not the only compilers and interpreters. These are not the only programs that could be written. These are not the only tasks that could be solved. These are just 10 tiny examples.

 2 : Are the Lua programs faster? Approximately.

Each table row shows, for one named benchmark, how much the fastest Lua program used compared to the fastest C++ g++ program.

(Memory use is only compared for tasks that require memory to be allocated.)

 Lua used what fraction? used how many times more? 
Benchmark Time Memory Code
 pidigits± ±
 regex-dna±±
 k-nucleotide1/2
 fasta12× ±
 reverse-complement23×1/4
 spectral-norm31× 1/3
 mandelbrot34× 1/3
 binary-trees41×1/2
 n-body51× ±
 fannkuch-redux78× 1/2
 Lua used what fraction? used how many times more? 
Time-used  |-  |---  25% median  75%  ---|  -|
(Elapsed secs)±±27×41×78×78×

± read the measurements and then read the program source code.

 3 : Are the Lua programs faster? Measurements.

These are not the only tasks that could be solved. These are just 10 tiny examples. These are not the only compilers and interpreters. These are not the only programs that could be written.

For each named benchmark, measurements of the fastest Lua program are shown for comparison against measurements of the fastest C++ g++ program.

Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
 pidigits 
Lua2.512.521,460479  0% 1% 1% 100%
C++ g++2.682.681,452682  0% 1% 4% 100%
 regex-dna 
Lua19.6919.71224,592669  0% 0% 0% 100%
C++ g++5.335.34170,488695  0% 0% 1% 100%
 k-nucleotide 
Lua220.11220.81707,928613  0% 0% 0% 100%
C++ g++24.0324.04138,9601252  1% 1% 0% 100%
 fasta 
Lua49.7149.721,1121049  0% 1% 0% 100%
C++ g++4.224.228721286  1% 1% 0% 100%
 reverse-complement 
Lua22.4922.51724,576555  0% 0% 0% 100%
C++ g++0.980.99245,6922275  3% 1% 0% 99%
 spectral-norm 
Lua243.58243.64940329  0% 0% 0% 100%
C++ g++7.927.939241044  0% 1% 1% 100%
 mandelbrot 
Lua786.43786.611,044353  0% 0% 0% 100%
C++ g++23.4423.4532,1801017  0% 1% 1% 100%
 binary-trees 
Lua449.99450.481,033,624446  0% 14% 4% 100%
C++ g++10.9210.94148,508892  1% 1% 0% 100%
 n-body 
Lua461.37461.478361193  0% 0% 0% 100%
C++ g++9.089.083361544  0% 0% 1% 100%
 fannkuch-redux 
Lua2,131.112,131.55820462  0% 0% 0% 100%
C++ g++27.2227.232841150  0% 1% 1% 100%
 fasta-redux 
No program
C++ g++0.020.03?1474  0% 0% 0% 100%

 4 : Are there other Lua programs for these benchmarks?

Remember - those are just the fastest Lua and C++ g++ programs measured on this OS/machine. Check if there are other implementations of these benchmark programs for Lua.

Maybe one of those other Lua programs is fastest on a different OS/machine.

 5 : Are there other faster programs for these benchmarks?

Remember - those are just the fastest Lua and C++ g++ programs measured on this OS/machine. Check if there are faster implementations of these benchmark programs for other programming languages.

Maybe one of those other programs is fastest on a different OS/machine.

 Lua : associative arrays for extensible embedded scripting 

online book "Programming in Lua" by Roberto Ierusalimschy

"Game Developers Conference 2010 Lua Tutorial" (slides)

Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio

Home Page: http://www.lua.org/

Download: http://www.lua.org/download.html

Revised BSD license

  Home   Conclusions   License   Play