Skip to content

Commit

Permalink
internal/readme: Use benchmarks submodule
Browse files Browse the repository at this point in the history
The benchmarks package has been placed inside its own module so that its
dependencies are not considered Zap's dependencies.

This changes the README update script to run the benchmark inside the
benchmark module's directory since we can no longer invoke it from Zap's
top-level directory.
  • Loading branch information
abhinav committed Oct 30, 2019
1 parent 5e6cfcd commit 7401f64
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions internal/readme/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func getBenchmarkRow(
return nil, err
}
r := &benchmarkRow{
Name: libraryNameToMarkdownName[libraryName],
Name: libraryNameToMarkdownName[libraryName],
Time: duration,
AllocatedBytes: allocatedBytes,
AllocatedObjects: allocatedObjects,
Expand Down Expand Up @@ -182,13 +182,11 @@ func findUniqueSubstring(input []string, substring string) (string, error) {
}

func getBenchmarkOutput(benchmarkName string) ([]string, error) {
return getOutput("go", "test", fmt.Sprintf("-bench=%s", benchmarkName), "-benchmem", "./benchmarks")
}

func getOutput(name string, arg ...string) ([]string, error) {
output, err := exec.Command(name, arg...).CombinedOutput()
cmd := exec.Command("go", "test", fmt.Sprintf("-bench=%s", benchmarkName), "-benchmem")
cmd.Dir = "benchmarks"
output, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("error running %s %s: %v\n%s", name, strings.Join(arg, " "), err, string(output))
return nil, fmt.Errorf("error running 'go test -bench=%q': %v\n%s", benchmarkName, err, string(output))
}
return strings.Split(string(output), "\n"), nil
}
Expand Down

0 comments on commit 7401f64

Please sign in to comment.