quantile: Use an if instead of math.Min

This significantly speeds up targeted streams when epsilon is small
because the invariant is called a lot.

benchmark                               old ns/op     new ns/op     delta
BenchmarkInsertTargetedSmallEpsilon     611           442           -27.66%
BenchmarkInsertTargeted                 188           171           -9.04%
BenchmarkInsertBiasedSmallEpsilon       833           914           +9.72%
BenchmarkQuery                          105           97.5          -7.14%
BenchmarkInsertBiased                   176           172           -2.27%
BenchmarkQuerySmallEpsilon              6599          6500          -1.50%
1 file changed
tree: 09ed9466a54af287efa81635c05f281e54681f9e
  1. histogram/
  2. quantile/
  3. topk/
  4. .gitignore
  5. README.md
README.md

Perks for Go (golang.org)

Perks contains the Go package quantile that computes approximate quantiles over an unbounded data stream within low memory and CPU bounds.

For more information and examples, see: http://godoc.org/github.com/bmizerany/perks

A very special thank you and shout out to Graham Cormode (Rutgers University), Flip Korn (AT&T Labs–Research), S. Muthukrishnan (Rutgers University), and Divesh Srivastava (AT&T Labs–Research) for their research and publication of Effective Computation of Biased Quantiles over Data Streams

Thank you, also:

  • Armon Dadgar (@armon)
  • Andrew Gerrand (@nf)
  • Brad Fitzpatrick (@bradfitz)
  • Keith Rarick (@kr)

FAQ:

Q: Why not move the quantile package into the project root? A: I want to add more packages to perks later.

Copyright (C) 2013 Blake Mizerany

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.