

#include <thrift/lib/cpp/test/loadgen/QpsScoreBoard.h>

namespace apache {
namespace thrift {
namespace loadgen {

void QpsScoreBoard::opStarted(uint32_t /* opType */) {}

void QpsScoreBoard::opSucceeded(uint32_t opType) {
  OpData* data = opData_.getOpData(opType);
  ++data->count;
}

void QpsScoreBoard::opFailed(uint32_t /* opType */) {}

uint64_t QpsScoreBoard::getCount(uint32_t opType) const {
  const OpData* data = opData_.getOpDataOrNull(opType);
  return data ? data->count : 0;
}

uint64_t QpsScoreBoard::computeTotalCount() const {
  OpData accumulated;
  opData_.accumulateOverOps(&accumulated);
  return accumulated.count;
}

void QpsScoreBoard::zero() {
  opData_.zero();
}

void QpsScoreBoard::accumulate(const QpsScoreBoard* other) {
  opData_.accumulate(&other->opData_);
}

} // namespace loadgen
} // namespace thrift
} // namespace apache
