作者: 谢瑞阳 10225101483 徐翔宇 10225101535
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

42 linhas
903 B

  1. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  4. #ifndef STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
  5. #define STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
  6. #include <string>
  7. namespace leveldb {
  8. class Histogram {
  9. public:
  10. Histogram() { }
  11. ~Histogram() { }
  12. void Clear();
  13. void Add(double value);
  14. void Merge(const Histogram& other);
  15. std::string ToString() const;
  16. private:
  17. double min_;
  18. double max_;
  19. double num_;
  20. double sum_;
  21. double sum_squares_;
  22. enum { kNumBuckets = 154 };
  23. static const double kBucketLimit[kNumBuckets];
  24. double buckets_[kNumBuckets];
  25. double Median() const;
  26. double Percentile(double p) const;
  27. double Average() const;
  28. double StandardDeviation() const;
  29. };
  30. }
  31. #endif // STORAGE_LEVELDB_UTIL_HISTOGRAM_H_