mirror of
https://github.com/google/go-jsonnet.git
synced 2025-08-07 23:07:14 +02:00
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
32 lines
587 B
Go
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()
|
|
}
|
|
}
|
|
}
|