MinMaxTimes.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Platform/Timers.h>
4 #include "MinMax.h"
5 
6 namespace Profiling
7 {
8 template <class Timer> class MinMaxTimes : public MinMax32, public Timer
9 {
10 public:
11  MinMaxTimes(const String& title) : MinMax32(title)
12  {
13  }
14 
16  {
17  MinMax32::update(this->elapsedTicks());
18  }
19 
21  {
22  return this->template ticksToTime(getMin());
23  }
24 
26  {
27  return this->template ticksToTime(getMax());
28  }
29 
31  {
32  return this->template ticksToTime(getAverage());
33  }
34 
36  {
37  return this->template ticksToTime(getTotal());
38  }
39 
40  size_t printTo(Print& p) const
41  {
42  auto res = p.print(getTitle());
43  res += p.print(": count=");
44  res += p.print(getCount());
45  res += p.print(", total=");
46  res += p.print(getTotalTime().toString());
47  res += p.print(", min=");
48  res += p.print(getMinTime().toString());
49  res += p.print(", max=");
50  res += p.print(getMaxTime().toString());
51  res += p.print(", average=");
52  res += p.print(getAverageTime().toString());
53  return res;
54  }
55 };
56 
60 
61 } // namespace Profiling
unsigned getCount() const
Definition: MinMax.h:55
T getTotal() const
Definition: MinMax.h:48
#define __forceinline
Definition: sming_attr.h:13
size_t printTo(Print &p) const
Definition: MinMaxTimes.h:40
size_t print(char c)
Prints a single character to output stream.
Definition: Print.h:93
NanoTime::Time< uint32_t > getMaxTime() const
Definition: MinMaxTimes.h:25
MinMaxTimes(const String &title)
Definition: MinMaxTimes.h:11
T getAverage() const
Definition: MinMax.h:89
NanoTime::Time< uint32_t > getTotalTime() const
Definition: MinMaxTimes.h:35
NanoTime::Time< uint32_t > getAverageTime() const
Definition: MinMaxTimes.h:30
The String class.
Definition: WString.h:136
NanoTime::Time< uint32_t > getMinTime() const
Definition: MinMaxTimes.h:20
Provides formatted output to stream.
Definition: Print.h:36
Definition: CpuUsage.h:4
void update(T value)
Definition: MinMax.h:76
T getMin() const
Definition: MinMax.h:38
T getMax() const
Definition: MinMax.h:43
const String & getTitle() const
Definition: MinMax.h:29
Class to handle a simple time value with associated unit.
Definition: NanoTime.h:123
String toString() const
Definition: CallbackTimer.h:45
Callback timer class.
Definition: Timer.h:255
void update()
Definition: MinMaxTimes.h:15
Class to track minimum and maximum values of a set of data, with average, total and count...
Definition: MinMax.h:22
Definition: MinMaxTimes.h:8