func()

in dev-tools/mage/benchmark.go [95:126]


func (Benchmark) Diff() error {
	mg.Deps(Benchmark.Deps)
	log.Println(">> running: benchstat")
	outputFile := os.Getenv("OUTPUT")
	baseFile := os.Getenv("BASE")
	nextFile := os.Getenv("NEXT")
	var args []string
	if baseFile == "" {
		log.Printf("Missing required parameter BASE parameter to parse the results. Please set this to a filepath of the benchmark results")
		return fmt.Errorf("missing required parameter BASE parameter to parse the results. Please set this to a filepath of the benchmark results")
	} else {
		args = append(args, baseFile)
	}
	if nextFile == "" {
		log.Printf("Missing NEXT parameter, we are not going to compare results")
	} else {
		args = append(args, nextFile)
	}

	_, err := runCommand(nil, "benchstat", outputFile, args...)

	var goTestErr *exec.ExitError
	switch {
	case goTestErr == nil:
		return nil
	case errors.As(err, &goTestErr):
		return fmt.Errorf("failed to execute benchstat command: %w", err)
	default:
		return fmt.Errorf("failed to execute benchstat command!! %w", err)
	}

}