Debian Codegraph @

analyzers/src/breakdown/latencies.h

raw symbols SCIP
1 //------------------------------------------------------------------------------
2 // Author: Andrey Kuznetsov
3 // Description: Latencies calculator
4 // Copyright (c) 2015 EPAM Systems
5 //------------------------------------------------------------------------------
6 /*
7 This file is part of Nfstrace.
8
9 Nfstrace is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, version 2 of the License.
12
13 Nfstrace is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
20 */
21 //------------------------------------------------------------------------------
22 #ifndef LATENCIES_H
23 #define LATENCIES_H
24 //------------------------------------------------------------------------------
25 #include <cstdint>
26
27 #include <sys/time.h>
28 //------------------------------------------------------------------------------
29 namespace NST
30 {
31 namespace breakdown
32 {
33 /*!
34 * \brief Latencies calculates latencies
35 */
36 class Latencies
37 {
38 public:
39 Latencies();
40
41 /*! Adds value of latency
42 * \param t - timeout
43 */
44 void add(const timeval& t);
45
46 /*!
47 * \brief gets count of timeouts
48 * \return count of timeouts
49 */
50 uint64_t get_count() const;
51
52 /*!
53 * \brief get_avg Gets average latency
54 * \return average timeout
55 */
56 long double get_avg() const;
57
58 /*!
59 * \brief get_st_dev Gets latency dispertion
60 * \return timeout dispertion
61 */
62 long double get_st_dev() const;
63
64 /*!
65 * \brief get_min Gets minimal value of latencies
66 * \return minimal latency
67 */
68 const timeval& get_min() const;
69
70 /*!
71 * \brief get_min Gets maximal value of latencies
72 * \return maximal latency
73 */
74 const timeval& get_max() const;
75
76 private:
77 void operator=(const Latencies&) = delete;
78
79 void set_range(const timeval& t);
80
81 timeval min;
82 timeval max;
83
84 uint64_t count;
85 long double avg;
86 long double m2;
87 };
88
89 /*!
90 * \brief to_sec Converts timeval to double
91 * \param val - time struct
92 * \return converted value
93 */
94 double to_sec(const timeval& val);
95
96 } // namespace breakdown
97 } // namespace NST
98 //------------------------------------------------------------------------------
99 #endif //LATENCIES_H
100 //------------------------------------------------------------------------------