Files
tensor/stats/bench_quantilereg_test.go
petrbalvin af4ee19703
Release / gates (push) Successful in 4m38s
Test / test (push) Successful in 5m16s
Release / release (push) Successful in 35s
feat: initial release
Assisted-by: GLM 5.3 Flash
2026-09-03 10:00:00 +02:00

39 lines
955 B
Go

// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: MIT
package stats
import (
"testing"
"sourcedock.dev/petrbalvin/tensor/internal/core"
)
// BenchmarkQuantileRegressionFit measures the interior-point quantile
// fit: the barrier Newton systems, the fraction-to-the-boundary walk
// and the primal recovery, at a size where the per-iteration system
// build is a visible share of the run.
func BenchmarkQuantileRegressionFit(b *testing.B) {
const n, p = 400, 8
x, vals := regDesign(b, n, p, 0x5eed0041)
src := &randSource{state: 0x5eed0042}
yv := make([]float64, n)
for i := range n {
eta := 0.5
for c := range p {
eta += 0.25 * vals[i*p+c]
}
yv[i] = eta + (src.next()-0.5)*0.5
}
y, err := core.FromFloats(yv, n)
if err != nil {
b.Fatal(err)
}
b.ReportAllocs()
for b.Loop() {
if _, err := QuantileRegression(x, y, 0.5); err != nil {
b.Fatal(err)
}
}
}