2013-10-16 23:59:46 +02:00
|
|
|
// Copyright (c) 2013, 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.
|
|
|
|
//
|
2012-05-30 08:18:16 +02:00
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
2013-10-05 07:32:05 +02:00
|
|
|
#pragma once
|
2012-11-03 05:02:40 +01:00
|
|
|
#include <cassert>
|
2012-05-30 08:18:16 +02:00
|
|
|
#include <stdlib.h>
|
2012-11-03 05:02:40 +01:00
|
|
|
#include <vector>
|
2013-05-23 20:34:58 +02:00
|
|
|
#include <memory>
|
2012-11-03 05:02:40 +01:00
|
|
|
|
2013-08-23 17:38:13 +02:00
|
|
|
#include "rocksdb/statistics.h"
|
2013-02-15 20:53:17 +01:00
|
|
|
#include "util/histogram.h"
|
2012-05-30 08:18:16 +02:00
|
|
|
#include "port/port.h"
|
|
|
|
#include "util/mutexlock.h"
|
2013-02-15 20:53:17 +01:00
|
|
|
|
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
namespace rocksdb {
|
2012-05-30 08:18:16 +02:00
|
|
|
|
|
|
|
class DBStatistics: public Statistics {
|
|
|
|
public:
|
2013-02-15 20:53:17 +01:00
|
|
|
DBStatistics() : allTickers_(TICKER_ENUM_MAX),
|
|
|
|
allHistograms_(HISTOGRAM_ENUM_MAX) { }
|
2012-05-30 08:18:16 +02:00
|
|
|
|
2013-02-15 20:53:17 +01:00
|
|
|
virtual ~DBStatistics() {}
|
|
|
|
|
|
|
|
virtual long getTickerCount(Tickers tickerType) {
|
2012-11-11 09:20:40 +01:00
|
|
|
assert(tickerType < TICKER_ENUM_MAX);
|
2012-11-03 05:02:40 +01:00
|
|
|
return allTickers_[tickerType].getCount();
|
|
|
|
}
|
|
|
|
|
2013-08-16 07:06:26 +02:00
|
|
|
virtual void setTickerCount(Tickers tickerType, uint64_t count) {
|
|
|
|
assert(tickerType < TICKER_ENUM_MAX);
|
|
|
|
allTickers_[tickerType].setTickerCount(count);
|
|
|
|
}
|
|
|
|
|
2013-02-15 20:53:17 +01:00
|
|
|
virtual void recordTick(Tickers tickerType, uint64_t count) {
|
2012-11-11 09:20:40 +01:00
|
|
|
assert(tickerType < TICKER_ENUM_MAX);
|
2013-01-16 01:48:22 +01:00
|
|
|
allTickers_[tickerType].recordTick(count);
|
2012-11-03 05:02:40 +01:00
|
|
|
}
|
|
|
|
|
2013-02-15 20:53:17 +01:00
|
|
|
virtual void measureTime(Histograms histogramType, uint64_t value) {
|
|
|
|
assert(histogramType < HISTOGRAM_ENUM_MAX);
|
|
|
|
allHistograms_[histogramType].Add(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void histogramData(Histograms histogramType,
|
|
|
|
HistogramData * const data) {
|
|
|
|
assert(histogramType < HISTOGRAM_ENUM_MAX);
|
|
|
|
allHistograms_[histogramType].Data(data);
|
|
|
|
}
|
|
|
|
|
2012-11-03 05:02:40 +01:00
|
|
|
std::vector<Ticker> allTickers_;
|
2013-02-15 20:53:17 +01:00
|
|
|
std::vector<HistogramImpl> allHistograms_;
|
2012-05-30 08:18:16 +02:00
|
|
|
};
|
2013-05-23 20:34:58 +02:00
|
|
|
|
|
|
|
std::shared_ptr<Statistics> CreateDBStatistics() {
|
|
|
|
return std::make_shared<DBStatistics>();
|
|
|
|
}
|
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
} // namespace rocksdb
|