package stats import ( "math" "testing" "salty/terrain/internal/field" ) // The whole reason this package was rewritten: the sorts could not be afforded at planet scale. 3000 x 3000 // is about what region 12 of the 100 km template is - 9 M cells, the largest single landmass - so this is the // cost of the biggest piece a bake ever hands over, and the planet is the sum of twenty of them. // // A benchmark rather than a test: it measures rather than asserts, and nothing here should fail a build. // // go test ./internal/stats/ -bench Region -benchtime 1x func BenchmarkRegionSizedAccumulate(b *testing.B) { const w, h, cellM = 3000, 3000, 8.0 f := field.New(w, h, cellM) land := make([]bool, w*h) up := make([]float32, w*h) for y := 0; y < h; y++ { for x := 0; x < w; x++ { i := y*w + x land[i] = true t := float64(x) / float64(w) f.Data[i] = float32(40 + 300*t*t + 18*math.Sin(float64(x)/9)*math.Cos(float64(y)/7)) up[i] = float32((0.02 + 0.9*t*t*t) / 1000) } } in := Input{H: f, Land: land, UpliftMYr: up} b.ResetTimer() for i := 0; i < b.N; i++ { a := New(testOptions()) a.Add(in) a.AddExtent(f.Data, land, 0) _ = a.Report(cellM) } b.ReportMetric(float64(w*h)/1e6, "Mcells") }