2012-05-30 06:18:16 +00: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.
|
|
|
|
|
2012-11-03 04:02:40 +00:00
|
|
|
#include <cassert>
|
2012-05-30 06:18:16 +00:00
|
|
|
#include <stdlib.h>
|
2012-11-03 04:02:40 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2012-05-30 06:18:16 +00:00
|
|
|
#include "leveldb/statistics.h"
|
|
|
|
#include "port/port.h"
|
|
|
|
#include "util/mutexlock.h"
|
|
|
|
namespace leveldb {
|
|
|
|
|
|
|
|
class DBStatistics: public Statistics {
|
|
|
|
public:
|
2012-11-03 04:02:40 +00:00
|
|
|
DBStatistics() : allTickers_(TICKER_ENUM_MAX) { }
|
2012-05-30 06:18:16 +00:00
|
|
|
|
|
|
|
void incNumFileOpens() {
|
|
|
|
MutexLock l(&mu_);
|
|
|
|
numFileOpens_++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void incNumFileCloses() {
|
|
|
|
MutexLock l(&mu_);
|
|
|
|
numFileCloses_++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void incNumFileErrors() {
|
|
|
|
MutexLock l(&mu_);
|
|
|
|
numFileErrors_++;
|
|
|
|
}
|
|
|
|
|
2012-11-03 04:02:40 +00:00
|
|
|
long getTickerCount(Tickers tickerType) {
|
2012-11-11 08:20:40 +00:00
|
|
|
assert(tickerType < TICKER_ENUM_MAX);
|
2012-11-03 04:02:40 +00:00
|
|
|
return allTickers_[tickerType].getCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
void recordTick(Tickers tickerType) {
|
2012-11-11 08:20:40 +00:00
|
|
|
assert(tickerType < TICKER_ENUM_MAX);
|
2012-11-03 04:02:40 +00:00
|
|
|
allTickers_[tickerType].recordTick();
|
|
|
|
}
|
|
|
|
|
2012-05-30 06:18:16 +00:00
|
|
|
private:
|
2012-11-03 04:02:40 +00:00
|
|
|
port::Mutex mu_;
|
|
|
|
std::vector<Ticker> allTickers_;
|
2012-05-30 06:18:16 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|