Skip to content

Commit

Permalink
seperate run and render (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
wlan0 authored Jan 26, 2022
1 parent 1c5143b commit eefa646
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
},
}

Expand Down
11 changes: 10 additions & 1 deletion pkg/dperf/perf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit eefa646

Please sign in to comment.