2 * Copyright 2012 Facebook, Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef FOLLY_DETAIL_STATS_H_
18 #define FOLLY_DETAIL_STATS_H_
22 namespace folly { namespace detail {
38 void add(const ValueType& s, uint64_t c) {
39 // TODO: It would be nice to handle overflow here.
44 Bucket& operator+=(const Bucket& o) {
49 Bucket& operator-=(const Bucket& o) {
50 // TODO: It would be nice to handle overflow here.
56 template <typename ReturnType>
57 ReturnType avg() const {
59 static_cast<ReturnType>(sum) / count :
69 #endif // FOLLY_DETAIL_STATS_H_