RTXI  3.0.0
The Real-Time eXperiment Interface Reference Manual
performance_measurement.hpp
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah,
4  Will Cornell Medical College
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 #ifndef PERFORMANCE_MEASUREMENT_H
22 #define PERFORMANCE_MEASUREMENT_H
23 
24 #include <QtWidgets>
25 
26 #include "math/runningstat.h"
27 #include "widgets.hpp"
28 #include "rt.hpp"
29 
30 
32 {
33 
34 constexpr std::string_view MODULE_NAME = "RT Benchmarks";
35 
36 inline std::vector<Widgets::Variable::Info> get_default_vars()
37 {
38  return
39  {
40  {
41  }
42  };
43 }
44 
46  double duration=0.0;
47  double timestep=0.0;
48  double latency=0.0;
49  double max_duration=0.0;
50  double max_timestep=0.0;
51  double max_latency=0.0;
52  double jitter=0.0;
53 };
54 
55 class Plugin : public Widgets::Plugin
56 {
57 public:
58  explicit Plugin(Event::Manager* ev_manager);
60 private:
61  RT::OS::Fifo* component_fifo;
62 }; // class Plugin
63 
65 {
66 public:
67  explicit Component(Widgets::Plugin* hplugin);
68 
69  void setTickPointers(int64_t* s_ticks, int64_t* e_ticks);
70  void execute() override;
71  RT::OS::Fifo* getFIfoPtr(){ return this->fifo.get(); }
72 
73 private:
74  performance_stats_t stats;
75 
76  //RunningStat timestepStat;
77  RunningStat latencyStat;
78 
79  int64_t *start_ticks=nullptr; // only accessed in rt
80  int64_t *end_ticks=nullptr; // only accessed in rt
81  int64_t last_start_ticks=0;
82  std::unique_ptr<RT::OS::Fifo> fifo;
83 };
84 
85 class Panel : public Widgets::Panel
86 {
87  Q_OBJECT
88 
89 public:
90  Panel(const std::string& mod_name, QMainWindow* mwindow, Event::Manager* ev_manager);
91 
92 public slots:
96  void reset();
97  //void resetMaxTimeStep();
101  void refresh() override;
102 
103 
104 private:
105  QLineEdit* durationEdit;
106  QLineEdit* timestepEdit;
107  QLineEdit* maxDurationEdit;
108  QLineEdit* maxTimestepEdit;
109  QLineEdit* timestepJitterEdit;
110  QLineEdit* AppCpuPercentEdit;
111 }; // class Panel
112 
113 std::unique_ptr<Widgets::Plugin> createRTXIPlugin(Event::Manager* ev_manager);
114 
115 Widgets::Panel* createRTXIPanel(QMainWindow* main_window, Event::Manager* ev_manager);
116 
117 std::unique_ptr<Widgets::Component> createRTXIComponent(Widgets::Plugin* host_plugin);
118 
120 } // namespace PerformanceMeasurement
121 #endif /* PERFORMANCE_MEASUREMENT_H */
void setTickPointers(int64_t *s_ticks, int64_t *e_ticks)
Panel(const std::string &mod_name, QMainWindow *mwindow, Event::Manager *ev_manager)
Plugin(Event::Manager *ev_manager)
Widgets::FactoryMethods getFactories()
std::unique_ptr< Widgets::Plugin > createRTXIPlugin(Event::Manager *ev_manager)
Widgets::Panel * createRTXIPanel(QMainWindow *main_window, Event::Manager *ev_manager)
std::vector< Widgets::Variable::Info > get_default_vars()
constexpr std::string_view MODULE_NAME
std::unique_ptr< Widgets::Component > createRTXIComponent(Widgets::Plugin *host_plugin)