diff --git a/cmd/cmd.go b/cmd/cmd.go index bb6b387..bc8cff5 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -92,7 +92,7 @@ $ dperf --serial /mnt/drive{1...6} } paths = append(paths, filepath.Clean(arg)) } - return perf.Run(c.Context(), paths...) + return perf.RunAndRender(c.Context(), paths...) }, } diff --git a/pkg/dperf/perf.go b/pkg/dperf/perf.go index 09ee41c..1a6d4bc 100644 --- a/pkg/dperf/perf.go +++ b/pkg/dperf/perf.go @@ -56,7 +56,7 @@ func (d *DrivePerf) runTests(ctx context.Context, path string) *DrivePerfResult } // Run drive performance -func (d *DrivePerf) Run(ctx context.Context, paths ...string) error { +func (d *DrivePerf) Run(ctx context.Context, paths ...string) ([]*DrivePerfResult, error) { parallelism := len(paths) if d.Serial { parallelism = 1 @@ -86,6 +86,15 @@ func (d *DrivePerf) Run(ctx context.Context, paths ...string) error { return results[i].ReadThroughput > results[j].ReadThroughput }) + return results, nil +} + +// Run drive performance and render it +func (d *DrivePerf) RunAndRender(ctx context.Context, paths ...string) error { + results, err := d.Run(ctx, paths...) + if err != nil { + return err + } d.render(results) return nil }