blob: 8701eea5b3890c253bf7dfc53e0d1d2393285bc7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "analyzer.h"
namespace vbench {
/**
* Component picking up the latency of successful requests and
* calculating relevant aggregated values.
**/
class LatencyAnalyzer : public Analyzer
{
private:
Handler<Request> &_next;
size_t _cnt;
double _min;
double _max;
double _total;
std::vector<size_t> _hist;
double getN(size_t n) const;
double getPercentile(double per) const;
public:
struct Stats {
double min;
double avg;
double max;
double per50;
double per95;
double per99;
Stats() : min(0), avg(0), max(0), per50(0), per95(0), per99(0) {}
string toString() const;
};
LatencyAnalyzer(Handler<Request> &next);
~LatencyAnalyzer() override;
void handle(Request::UP request) override;
void report() override;
void addLatency(double latency);
Stats getStats() const;
};
} // namespace vbench
|