Skip to content

Commit

Permalink
Fixed sorting of plugins and improved formatting of time.
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Wulff committed Dec 10, 2024
1 parent c8043e5 commit 9bbab73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions internal/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"os/exec"
"path/filepath"
"plugin"
"sort"
"strconv"
"strings"
)

Expand Down Expand Up @@ -124,6 +126,7 @@ func GetProcessors(args Args) ([]PluginProcessor, error) {
Day: parts[day][3:],
Part: parts[part][4 : len(parts[part])-3],
}

args.path, err = args.getPath()
if err != nil {
return err
Expand All @@ -142,5 +145,11 @@ func GetProcessors(args Args) ([]PluginProcessor, error) {
return nil, err
}

sort.Slice(processors, func(i, j int) bool {
l, _ := strconv.Atoi(processors[i].Args.Day)
r, _ := strconv.Atoi(processors[j].Args.Day)
return l < r
})

return processors, nil
}
4 changes: 2 additions & 2 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func Run() {
for _, p := range plugins {
sum += p.Benchmark.GetTotalTime()
// @TODO: would be nice to join day & parts in a single row, but for now it's already nice they're alphabetically sorted
fmt.Fprintf(w, "%s\t%s\t%v\n", p.Args.Day, p.Args.Part, p.Benchmark.GetTotalTime())
fmt.Fprintf(w, "%s\t%s\t%8.3f\n", p.Args.Day, p.Args.Part, p.Benchmark.GetTotalTime())
}
w.Flush()

fmt.Printf("\nTotal time: %v ms\n", sum)
fmt.Printf("\nTotal time: %.3f ms\n", sum)
}

0 comments on commit 9bbab73

Please sign in to comment.