aboutsummaryrefslogtreecommitdiff
path: root/cli/cli.go
diff options
context:
space:
mode:
Diffstat (limited to 'cli/cli.go')
-rw-r--r--cli/cli.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/cli/cli.go b/cli/cli.go
index d3aff22..4459946 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -32,6 +32,8 @@ var (
backtest = flag.Bool("backtest", false, "run data benchmarks comparing computed values against stored reference values")
)
+const backtestMinimumElapsedTimeS = 15 * 60
+
func Run(db *sql.DB, configPath string, appConfig config.Config) {
switch {
case *download:
@@ -84,7 +86,7 @@ func runBacktest(db *sql.DB) error {
if i > 0 && i%50 == 0 {
slog.Info("Backtest progress", "processed", i, "total", len(items))
}
- if item.GPXPath == "" {
+ if !isBacktestEligible(item) {
continue
}
parsed, err := ride.ParseFile(ride.GPXRideParser{}, item.GPXPath)
@@ -93,9 +95,6 @@ func runBacktest(db *sql.DB) error {
continue
}
reference := time.Duration(item.MovingTimeS) * time.Second
- if reference <= 0 {
- continue
- }
computed := ride.MovingTime(parsed)
samples = append(samples, backtestSample{
externalID: item.ExternalID,
@@ -135,10 +134,14 @@ func runBacktest(db *sql.DB) error {
fmt.Fprintf(table, "p%g\t%.1f\n", p, distribution[p])
}
table.Flush()
- slog.Info("Moving time backtest", "rides", len(samples), "mean_err_pct", math.Round(meanAbsErr(absErrors)*10)/10, "stderr_pct", math.Round(stdErrAbsErr(absErrors)*10)/10)
+ slog.Info("Moving time backtest", "rides", len(samples), "min_elapsed_s", backtestMinimumElapsedTimeS, "mean_err_pct", math.Round(meanAbsErr(absErrors)*10)/10, "stderr_pct", math.Round(stdErrAbsErr(absErrors)*10)/10)
return nil
}
+func isBacktestEligible(item rides.Ride) bool {
+ return item.GPXPath != "" && item.ElapsedTimeS >= backtestMinimumElapsedTimeS && item.MovingTimeS > 0
+}
+
func meanAbsErr(absErrors []float64) float64 {
var sum float64
for _, err := range absErrors {