aboutsummaryrefslogtreecommitdiffstats
path: root/yt/yt/library/profiling/summary.h
blob: 29768d1e2b0e558e3ed13d979ee0f5ee8c1a1272 (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
#pragma once

#include <util/system/types.h>

namespace NYT::NProfiling {

////////////////////////////////////////////////////////////////////////////////

template <class T>
class TSummarySnapshot
{
public:
    void Record(T value);
    void Add(const TSummarySnapshot& other);

    TSummarySnapshot<T>& operator += (const TSummarySnapshot& other);
    TSummarySnapshot() = default;
    TSummarySnapshot(T sum, T min, T max, T last, i64 count);

    bool operator == (const TSummarySnapshot& other) const;
    bool operator != (const TSummarySnapshot& other) const;

    T Sum() const;
    T Min() const;
    T Max() const;
    T Last() const;
    i64 Count() const;

private:
    T Sum_{}, Min_{}, Max_{}, Last_{};
    i64 Count_ = 0;
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT::NProfiling

#define SUMMARY_INL_H_
#include "summary-inl.h"
#undef SUMMARY_INL_H_