package fluvial import "testing" // What the two accumulators cost per cell, which is the number a bake's wall clock is spent against. Both are // measured on the same surface with the receivers and the stack already built, because those are shared. func benchAccumulate(b *testing.B, mfd bool) { const n = 1024 h := planarRamp(n, 8.0, 0.1, 22.5) g := NewGrid(n, n, 8.0, nil) g.SetSeed(37125) g.FillDepressions(h, 1e-3) g.ComputeReceivers(h) g.BuildStack() b.ResetTimer() for i := 0; i < b.N; i++ { if mfd { g.AccumulateMFD(h, 1) } else { g.Accumulate() } } b.ReportMetric(float64(b.Elapsed().Nanoseconds())/float64(b.N)/float64(n*n), "ns/cell") } func BenchmarkAccumulateD8(b *testing.B) { benchAccumulate(b, false) } func BenchmarkAccumulateMFD(b *testing.B) { benchAccumulate(b, true) }