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 
15  __forceinline void update()
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
NanoTime::Time< uint32_t > getMinTime() const
Definition: MinMaxTimes.h:20
size_t print(char c)
Prints a single character to output stream.
Definition: Print.h:97
MinMaxTimes(const String &title)
Definition: MinMaxTimes.h:11
The String class.
Definition: WString.h:136
T getTotal() const
Definition: MinMax.h:64
T getMax() const
Definition: MinMax.h:59
Callback timer class.
Definition: Timer.h:262
Definition: CpuUsage.h:4
size_t printTo(Print &p) const
Definition: MinMaxTimes.h:40
void update()
Definition: MinMaxTimes.h:15
T getAverage() const
Definition: MinMax.h:97
Definition: MinMaxTimes.h:8
const String & getTitle() const
Definition: MinMax.h:45
void update(T value)
Definition: MinMax.h:84
Provides formatted output to stream.
Definition: Print.h:36
NanoTime::Time< uint32_t > getMaxTime() const
Definition: MinMaxTimes.h:25
Class to track minimum and maximum values of a set of data, with average, total and count.
Definition: MinMax.h:30
String toString() const
Definition: CallbackTimer.h:45
NanoTime::Time< uint32_t > getAverageTime() const
Definition: MinMaxTimes.h:30
NanoTime::Time< uint32_t > getTotalTime() const
Definition: MinMaxTimes.h:35
T getMin() const
Definition: MinMax.h:54
unsigned getCount() const
Definition: MinMax.h:71