go_goja_gopherlua_benchmark/gopherlua_bench_test.go
2024-03-09 10:01:17 +03:30

26 lines
506 B
Go

package main
import (
"testing"
lua "github.com/yuin/gopher-lua"
)
func BenchmarkGopherLuaNumericalCalculation(b *testing.B) {
L := lua.NewState()
defer L.Close()
b.ResetTimer()
for i := 0; i < b.N; i++ {
L.DoString("sum = 0; for i = 1, 1000000 do sum = sum + i end")
}
}
func BenchmarkGopherLuaStringManipulation(b *testing.B) {
L := lua.NewState()
defer L.Close()
b.ResetTimer()
for i := 0; i < b.N; i++ {
L.DoString(`result = ""; for i = 1, 10000 do result = result .. "a" end`)
}
}