metrics/histogram.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2018 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include "glog/logging.h"
20 
21 namespace cartographer {
22 namespace metrics {
23 
24 namespace {
25 
26 // Implementation of histogram that does nothing.
27 class NullHistogram : public Histogram {
28  public:
29  void Observe(double) override {}
30 };
31 
32 } // namespace
33 
35  static NullHistogram null_histogram;
36  return &null_histogram;
37 }
38 
40  int num_finite_buckets) {
41  BucketBoundaries result;
42  double boundary = 0;
43  for (int i = 0; i < num_finite_buckets; ++i) {
44  boundary += width;
45  result.push_back(boundary);
46  }
47  return result;
48 }
49 
51  double scale_factor,
52  double max_value) {
53  CHECK_GT(base, 1);
54  CHECK_GT(scale_factor, 0);
55  BucketBoundaries result;
56  double boundary = scale_factor;
57  while (boundary < max_value) {
58  result.push_back(boundary);
59  boundary *= base;
60  }
61  return result;
62 }
63 
64 } // namespace metrics
65 } // namespace cartographer
static BucketBoundaries FixedWidth(double width, int num_finite_buckets)
std::vector< double > BucketBoundaries
static BucketBoundaries ScaledPowersOf(double base, double scale_factor, double max_value)


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58