PerformanceMonitor.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00023 //----------------------------------------------------------------------/*
00024 
00025 #ifndef ICL_CORE_TIMER_H
00026 #define ICL_CORE_TIMER_H
00027 
00028 #include <string>
00029 #include <vector>
00030 #include <map>
00031 #include <ostream>
00032 
00033 #include "icl_core_performance_monitor/logging_performance_monitor.h"
00034 #include "icl_core_performance_monitor/PerformanceMonitorMacros.h"
00035 #include "icl_core_performance_monitor/ImportExport.h"
00036 
00037 
00038 #include <icl_core/TimeStamp.h>
00039 
00040 namespace icl_core {
00041 namespace perf_mon{
00042 
00043 
00069 class ICL_CORE_PERFORMANCE_MONITOR_EXPORT PerformanceMonitor
00070 {
00071 public:
00078   static PerformanceMonitor* getInstance();
00079 
00088   static void initialize(const uint32_t num_names, const uint32_t num_events);
00089 
00094   static void start(std::string timer_name);
00095 
00105   static double measurement(std::string timer_name, std::string description, std::string prefix = "",
00106                           logging::LogLevel level = icl_core::logging::eLL_INFO);
00107 
00118   static double startStop(std::string timer_name, std::string description, std::string prefix = "",
00119                           logging::LogLevel level = icl_core::logging::eLL_INFO);
00120 
00127   static void addData(std::string name, double data, std::string prefix);
00128 
00136   static void addStaticData(std::string name, double data, std::string prefix);
00137 
00146   static void addNonTimeData(std::string name, double data, std::string prefix);
00147 
00152   static void enablePrefix(std::string prefix);
00153 
00160   static void enableAll(const bool& enabled);
00161 
00166   static void disablePrefix(std::string prefix);
00167 
00174   static void printSummary(std::string prefix, std::string name,
00175                            icl_core::logging::LogLevel level = icl_core::logging::eLL_INFO);
00176 
00183   static void printSummaryAll(icl_core::logging::LogLevel level = icl_core::logging::eLL_INFO);
00184 
00185 
00191   static void printSummaryFromPrefix(std::string prefix, icl_core::logging::LogLevel level = icl_core::logging::eLL_INFO);
00192 
00194   bool m_enabled;
00196   bool m_print_stop;
00197 
00198 protected:
00200   PerformanceMonitor();
00202   ~PerformanceMonitor();
00203 
00205   void createStatisticSummary(std::stringstream& ss, std::string prefix, std::string name);
00206   void createStatisticSummaryNonTime(std::stringstream& ss, std::string prefix, std::string name);
00207 
00208 
00210   void print(std::string message, icl_core::logging::LogLevel level = icl_core::logging::eLL_DEBUG);
00211 
00213   void addEvent(std::string prefix, std::string name, double data);
00214   void addNonTimeEvent(std::string prefix, std::string name, double data);
00215 
00217   bool isEnabled(std::string prefix);
00218 
00220   double getAverage(std::string name);
00221   double getAverageNonTime(std::string name);
00222 
00224   void getMedian(std::string name, double& median, double& min, double& max);
00225   void getMedianNonTime(std::string name, double& median, double& min, double& max);
00226 
00227   std::map<std::string, std::vector<double> > m_data;
00228   std::map<std::string, std::vector<double> > m_data_nontime;
00229   std::map<std::string, TimeStamp> m_timer;
00230   std::vector<std::vector<double> > m_buffer;
00231   std::map<std::string, bool> m_enabled_prefix;
00232   std::map<std::string, double > m_static_data;
00233 
00234   bool m_all_enabled;
00235 
00236 
00237 private:
00238   static PerformanceMonitor* m_instance;
00239 };
00240 
00241 
00242 } // namespace perf_mon
00243 } // namespace icl_core
00244 
00245 #endif /* ICL_CORE_TIMER_H */


fzi_icl_core
Author(s):
autogenerated on Tue Aug 8 2017 02:28:03