Go embedded languages benchmarks
Here are some benchmarks that compare Go embedded interpreters. The benchmark code can be found on this repository, contributions to improve the accuracy of these benchmarks are welcome.
The results presented in this page have been obtained with the following configuration:
goos: linux goarch: amd64 pkg: scriggo-bench cpu: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
Fibonacci 10
Execution of a recursive algorithm for the calculation of Fibonacci(10)
BenchmarkScriggo/Fibonacci-10.go-4 119041 31036 ns/op 32016 B/op 11 allocs/op BenchmarkYaegi/Fibonacci-10.go-4 17040 204628 ns/op 107994 B/op 2307 allocs/op BenchmarkTengo/Fibonacci-10.tengo-4 28179 156631 ns/op 127315 B/op 638 allocs/op BenchmarkGoLua/Fibonacci-10.lua-4 71122 50439 ns/op 9360 B/op 319 allocs/op BenchmarkGopherLua/Fibonacci-10.lua-4 37770 95907 ns/op 52608 B/op 247 allocs/op BenchmarkGoja/Fibonacci-10.js-4 12464 281745 ns/op 148735 B/op 1874 allocs/op
Fibonacci 35
Execution of a recursive algorithm for the calculation of Fibonacci(35)
BenchmarkScriggo/Fibonacci-35.go-4 2 2533204486 ns/op 41232 B/op 13 allocs/op BenchmarkYaegi/Fibonacci-35.go-4 1 25250780073 ns/op 12541598176 B/op 283677612 allocs/op BenchmarkTengo/Fibonacci-35.tengo-4 1 3513278597 ns/op 312832672 B/op 39088586 allocs/op BenchmarkGoLua/Fibonacci-35.lua-4 1 6098240439 ns/op 312721184 B/op 39088310 allocs/op BenchmarkGopherLua/Fibonacci-35.lua-4 1 6541278043 ns/op 1023624 B/op 4040 allocs/op BenchmarkGoja/Fibonacci-35.js-4 1 7071025456 ns/op 531568 B/op 48247 allocs/op
Closures
Declaration and execution of a closure inside a loop
BenchmarkScriggo/closures.go-4 100 30137289 ns/op 7949160 B/op 180009 allocs/op BenchmarkYaegi/closures.go-4 46 78739229 ns/op 69149390 B/op 540515 allocs/op BenchmarkTengo/closures.tengo-4 284 12816051 ns/op 1563110 B/op 180277 allocs/op BenchmarkGoLua/closures.lua-4 100 34017255 ns/op 3607691 B/op 360087 allocs/op BenchmarkGopherLua/closures.lua-4 100 33929424 ns/op 7968536 B/op 98620 allocs/op BenchmarkGoja/closures.js-4 22 148275304 ns/op 69984461 B/op 1081331 allocs/op
Iterations
Nested iterations and assignments on a slice of integers
BenchmarkScriggo/iterations.go-4 266 13189727 ns/op 32264 B/op 8 allocs/op BenchmarkYaegi/iterations.go-4 356 9986679 ns/op 53830 B/op 1031 allocs/op BenchmarkTengo/iterations.tengo-4 70 46213939 ns/op 9150638 B/op 803199 allocs/op BenchmarkGoLua/iterations.lua-4 100 32757354 ns/op 2601145 B/op 322111 allocs/op BenchmarkGopherLua/iterations.lua-4 80 47441700 ns/op 3897215 B/op 326059 allocs/op BenchmarkGoja/iterations.js-4 25 137370169 ns/op 12806214 B/op 772259 allocs/op
Strings
Strings concatenation and rune search
go-lua and GopherLua are not represented here as the test program was not portable to Lua5.1
BenchmarkScriggo/strings.go-4 18784 195300 ns/op 51769 B/op 805 allocs/op BenchmarkYaegi/strings.go-4 10000 371228 ns/op 202841 B/op 1879 allocs/op BenchmarkTengo/strings.tengo-4 10000 310193 ns/op 172660 B/op 2695 allocs/op BenchmarkGoja/strings.js-4 4629 734536 ns/op 216695 B/op 4236 allocs/op