sapling/eden/fs/fuse/EdenStats.cpp
Chad Austin 8b9261f2a1 run clang-format across all C++ files
Summary:
Per discussion with bolinfest, this brings Eden in line with clang-format.

This diff was generated with `find . \( -iname '*.cpp' -o -iname '*.h' \) -exec bash -c "yes | arc lint {}" \;`

Reviewed By: bolinfest

Differential Revision: D6232695

fbshipit-source-id: d54942bf1c69b5b0dcd4df629f1f2d5538c9e28c
2017-11-03 16:02:03 -07:00

76 lines
2.0 KiB
C++

/*
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#include "EdenStats.h"
#include <folly/container/Array.h>
#include <chrono>
using namespace folly;
using namespace std::chrono;
namespace {
constexpr std::chrono::microseconds kMinValue{0};
constexpr std::chrono::microseconds kMaxValue{10000};
constexpr std::chrono::microseconds kBucketSize{1000};
constexpr unsigned int kNumTimeseriesBuckets{60};
constexpr auto kDurations = folly::make_array(
std::chrono::seconds(60),
std::chrono::seconds(600),
std::chrono::seconds(3600),
std::chrono::seconds(0));
} // namespace
namespace facebook {
namespace eden {
namespace fusell {
EdenStats::EdenStats() {}
#if EDEN_HAS_COMMON_STATS
EdenStats::Histogram EdenStats::createHistogram(const std::string& name) {
return Histogram{this,
name,
kBucketSize.count(),
kMinValue.count(),
kMaxValue.count(),
facebook::stats::COUNT,
50,
90,
99};
}
#else
folly::TimeseriesHistogram<int64_t> EdenStats::createHistogram(
const std::string& /* name */) {
return folly::TimeseriesHistogram<int64_t>{
kBucketSize.count(),
kMinValue.count(),
kMaxValue.count(),
MultiLevelTimeSeries<int64_t>{
kNumTimeseriesBuckets, kDurations.size(), kDurations.data()}};
}
#endif
void EdenStats::recordLatency(
HistogramPtr item,
std::chrono::microseconds elapsed,
std::chrono::seconds now) {
#if EDEN_HAS_COMMON_STATS
(void)now; // we don't use it in this code path
(this->*item).addValue(elapsed.count());
#else
(this->*item)->addValue(now, elapsed.count());
#endif
}
} // namespace fusell
} // namespace eden
} // namespace facebook