go-jsonnet/builtins_benchmark_test.go
Weston McNamee 27b4c60bc7 feat: Improve performance of substr by 84.44%
This pulls in the implementation of substr into native Go instead of interpretted Jsonnet.

benchmark                       old ns/op     new ns/op     delta
Benchmark_Builtin_substr-16     97121527      15115905      -84.44%

part of #111
2020-01-26 09:20:58 +01:00

32 lines
587 B
Go

package jsonnet
import (
"flag"
"os"
"os/exec"
"testing"
)
var jsonnetPath string
var outputPassthru bool
func init() {
flag.StringVar(&jsonnetPath, "jsonnetPath", "./jsonnet", "Path to jsonnet binary")
flag.BoolVar(&outputPassthru, "outputPassthru", false, "Pass stdout/err from jsonnet")
}
func Benchmark_Builtin_substr(b *testing.B) {
for n := 0; n < b.N; n++ {
cmd := exec.Command(jsonnetPath, "./builtin-benchmarks/substr.jsonnet")
if outputPassthru {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}
err := cmd.Run()
if err != nil {
b.Fail()
}
}
}