blob: bca39d0a7355f93f8ace3b6d74b4c6e8e1df9d74 (
plain)
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
|
// Copyright (C) 2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <map>
#include <string>
#include <utility>
#include <vector>
// clang-format off
#include "samples/common.hpp"
#include "samples/slog.hpp"
// clang-format on
/// @brief Responsible for calculating different latency metrics
class LatencyMetrics {
public:
LatencyMetrics() {}
LatencyMetrics(const std::vector<double>& latencies,
const std::string& data_shape = "",
size_t percentile_boundary = 50)
: data_shape(data_shape),
percentile_boundary(percentile_boundary) {
fill_data(latencies, percentile_boundary);
}
void write_to_stream(std::ostream& stream) const;
void write_to_slog() const;
double median_or_percentile = 0;
double avg = 0;
double min = 0;
double max = 0;
std::string data_shape;
private:
void fill_data(std::vector<double> latencies, size_t percentile_boundary);
size_t percentile_boundary = 50;
};
|