aboutsummaryrefslogtreecommitdiff
path: root/cli/cli.go
diff options
context:
space:
mode:
Diffstat (limited to 'cli/cli.go')
-rw-r--r--cli/cli.go10
1 files changed, 2 insertions, 8 deletions
diff --git a/cli/cli.go b/cli/cli.go
index 3f291bb..52b5a8c 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -106,10 +106,7 @@ func runBacktest(db *sql.DB) error {
})
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w, "computed\treference\terr %\tride")
- limit := 10
- if len(samples) < limit {
- limit = len(samples)
- }
+ limit := min(len(samples), 10)
for _, s := range samples[:limit] {
fmt.Fprintf(w, "%s\t%s\t%+.1f\t%s (%s)\n", s.computed.Round(time.Second), s.reference.Round(time.Second), s.relErrorPct, s.name, s.externalID)
}
@@ -162,10 +159,7 @@ func errorDistribution(absErrors []float64, percentiles []float64) map[float64]f
sort.Float64s(sorted)
distribution := map[float64]float64{}
for _, p := range percentiles {
- index := int(math.Ceil(p/100*float64(len(sorted))) - 1)
- if index < 0 {
- index = 0
- }
+ index := max(int(math.Ceil(p/100*float64(len(sorted)))-1), 0)
if index >= len(sorted) {
index = len(sorted) - 1
}