26 lines
506 B
Go
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`)
|
|
}
|
|
}
|