cmd/bench: change goTestSubrepo to run sub repo experiment as toolchain experiment.

Change-Id: I3ccfbb22422034c01814fc4a247518c4d28e2cda
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/458917
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dylan Le <dungtuanle@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
diff --git a/cmd/bench/gotest.go b/cmd/bench/gotest.go
index 5e5301c..b2f811d 100644
--- a/cmd/bench/gotest.go
+++ b/cmd/bench/gotest.go
@@ -22,18 +22,23 @@
 	return nil
 }
 
-func goTestSubrepo(tc *toolchain, subRepo string, dirs []string) error {
+func goTestSubrepo(tc *toolchain, subRepo, baselineDir, experimentDir string) error {
 	switch subRepo {
 	case "tools":
 		log.Printf("Running sub-repo benchmarks for %s", subRepo)
-		fmt.Printf("toolchain: %s\n", tc.Name)
 
-		for _, dir := range dirs {
-			err := tc.Do(filepath.Join(dir, "gopls"), "test", "-v", "-bench=BenchmarkGoToDefinition", "./internal/regtest/bench/", "-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, dir, err)
-			}
+		fmt.Println("toolchain: baseline")
+		err := tc.Do(filepath.Join(baselineDir, "gopls"), "test", "-v", "-bench=BenchmarkGoToDefinition", "./internal/regtest/bench/", "-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")
+		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)
 		}
 	default:
 		return fmt.Errorf("unsupported subrepo %s", subRepo)
diff --git a/cmd/bench/main.go b/cmd/bench/main.go
index ae634b0..d4eb165 100644
--- a/cmd/bench/main.go
+++ b/cmd/bench/main.go
@@ -151,11 +151,10 @@
 	if subRepoBaseline == "" {
 		subRepoBaseline = os.Getenv("BENCH_SUBREPO_BASELINE_PATH")
 	}
-	dirs := []string{subRepoExperiment, subRepoBaseline}
 
 	if repository != "go" {
 		toolchain := toolchainFromGOROOT("baseline", gorootBaseline)
-		if err := goTestSubrepo(toolchain, repository, dirs); err != nil {
+		if err := goTestSubrepo(toolchain, repository, subRepoBaseline, subRepoExperiment); err != nil {
 			log.Print("FAIL")
 			os.Exit(1)
 		}