cmd/bench: run experiment benchmarks for both baseline and experiment gopls
Build baseline and experiment gopls within their respective directories and run experiment benchmarks using gopls_path flag.
Change-Id: Ifcc9aa9107257bac215361b71f87e419db339b97
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/461797
Run-TryBot: Dylan Le <dungtuanle@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/cmd/bench/gotest.go b/cmd/bench/gotest.go
index b2f811d..87048af 100644
--- a/cmd/bench/gotest.go
+++ b/cmd/bench/gotest.go
@@ -27,15 +27,31 @@
case "tools":
log.Printf("Running sub-repo benchmarks for %s", subRepo)
+ // Build baseline gopls binary to run benchmark on
+ goplsBaseline := filepath.Join(baselineDir, "gopls")
+ err := tc.Do(goplsBaseline, "build")
+ if err != nil {
+ log.Printf("Error: %v", err)
+ return fmt.Errorf("error building sub-repo %s with toolchain %s in dir %s: %w", subRepo, tc.Name, baselineDir, err)
+ }
+
+ // Build experiment gopls binary to run benchmark on
+ goplsExperiment := filepath.Join(experimentDir, "gopls")
+ err = tc.Do(goplsExperiment, "build")
+ if err != nil {
+ log.Printf("Error: %v", err)
+ return fmt.Errorf("error building sub-repo %s with toolchain %s in dir %s: %w", subRepo, tc.Name, experimentDir, err)
+ }
+
fmt.Println("toolchain: baseline")
- err := tc.Do(filepath.Join(baselineDir, "gopls"), "test", "-v", "-bench=BenchmarkGoToDefinition", "./internal/regtest/bench/", "-count=5")
+ err = tc.Do(goplsExperiment, "test", "-v", "-bench=BenchmarkGoToDefinition", "./internal/regtest/bench/", fmt.Sprintf(`-gopls_path=%s`, filepath.Join(goplsBaseline, "gopls")), "-count=5")
if err != nil {
log.Printf("Error: %v", err)
return fmt.Errorf("error running sub-repo %s benchmark with toolchain %s in dir %s: %w", subRepo, tc.Name, baselineDir, err)
}
fmt.Println("toolchain: experiment")
- err = tc.Do(filepath.Join(experimentDir, "gopls"), "test", "-v", "-bench=BenchmarkGoToDefinition", "./internal/regtest/bench/", "-count=5")
+ err = tc.Do(goplsExperiment, "test", "-v", "-bench=BenchmarkGoToDefinition", "./internal/regtest/bench/", fmt.Sprintf(`-gopls_path=%s`, filepath.Join(goplsExperiment, "gopls")), "-count=5")
if err != nil {
log.Printf("Error: %v", err)
return fmt.Errorf("error running sub-repo %s benchmark with toolchain %s in dir %s: %w", subRepo, tc.Name, experimentDir, err)