Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'base/time_samples.hpp')
-rw-r--r--base/time_samples.hpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/base/time_samples.hpp b/base/time_samples.hpp
index b37166b164..c4f1fdf072 100644
--- a/base/time_samples.hpp
+++ b/base/time_samples.hpp
@@ -6,21 +6,35 @@
namespace my
{
+// This class can be used in measurements of code blocks performance.
+// It can accumulate time samples, and can calculate mean time and
+// standard deviation.
+//
+// *NOTE* This class is NOT thread-safe.
class TimeSamples final
{
public:
- void Add(double s);
+ void Add(double seconds);
+ // Mean of the accumulated time samples.
double GetMean() const;
- double GetSd() const;
+
+ // Unbiased standard deviation of the accumulated time samples.
+ double GetSD() const;
+
+ // Unbiased variance of the accumulated time samples.
double GetVar() const;
private:
- double m_s = 0.0;
- double m_s2 = 0.0;
+ double m_sum = 0.0;
+ double m_sum2 = 0.0;
size_t m_total = 0;
};
+// This class can be used as a single scoped time sample. It
+// automatically adds time sample on destruction.
+//
+// *NOTE* This class is NOT thread-safe.
class ScopedTimeSample final
{
public: