# HG changeset patch # User Sascha L. Teichmann # Date 1558531715 -7200 # Node ID ff79a9b6707f0b485081e9c1889b58631fb13888 # Parent ccb5455f071329b84bfdb3e82deb66c754c48f53 waterlevel classification: Re-enable finding a good starting points for classification intervals. diff -r ccb5455f0713 -r ff79a9b6707f pkg/controllers/bottlenecks.go --- a/pkg/controllers/bottlenecks.go Wed May 22 15:11:58 2019 +0200 +++ b/pkg/controllers/bottlenecks.go Wed May 22 15:28:35 2019 +0200 @@ -145,7 +145,21 @@ classes[i+1] = breaks[i].value } - // TODO: Find a good starting point with binary or interpolation search. + idx := sort.Search(len(measurements), func(i int) bool { + // All values before from can be ignored. + return !measurements[i].when.Before(from) + }) + + if idx >= len(measurements) { + return result + } + + // Be safe for interpolation. + if idx > 0 { + idx-- + } + + measurements = measurements[idx:] for i := 0; i < len(measurements)-1; i++ { p1 := &measurements[i]