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-02-15 20:53:17 +01:00
|
|
|
#ifndef LEVELDB_STORAGE_DB_DB_STATISTICS_H_
|
|
|
|
#define LEVELDB_STORAGE_DB_DB_STATISTICS_H_
|
|
|
|
|
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>
|
|
|
|
|
2012-05-30 08:18:16 +02:00
|
|
|
#include "leveldb/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
|
|
|
|
|
|
|
|
2012-05-30 08:18:16 +02:00
|
|
|
namespace leveldb {
|
|
|
|
|
|
|
|
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-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-02-15 20:53:17 +01:00
|
|
|
} // namespace leveldb
|
|
|
|
|
|
|
|
#endif // LEVELDB_STORAGE_DB_DB_STATISTICS_H_
|
2012-05-30 08:18:16 +02:00
|
|
|
|
|
|
|
|