ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 47:9e361da97763 1 #ifndef __MEASURETIME_H__
TMBOY 47:9e361da97763 2 #define __MEASURETIME_H__
TMBOY 47:9e361da97763 3
TMBOY 47:9e361da97763 4 #include <string>
TMBOY 47:9e361da97763 5 #include <map>
TMBOY 47:9e361da97763 6 #include <stdio.h>
TMBOY 47:9e361da97763 7
TMBOY 47:9e361da97763 8 #define print_error printf
TMBOY 47:9e361da97763 9
TMBOY 47:9e361da97763 10 int time_current_get(void);
TMBOY 47:9e361da97763 11
TMBOY 47:9e361da97763 12 namespace baidu{
TMBOY 47:9e361da97763 13 namespace os{
TMBOY 47:9e361da97763 14
TMBOY 47:9e361da97763 15 typedef struct __MeasureValue{
TMBOY 47:9e361da97763 16 unsigned int total_cnt;
TMBOY 47:9e361da97763 17 unsigned int cur_cnt;
TMBOY 47:9e361da97763 18 unsigned int time_begin;
TMBOY 47:9e361da97763 19 unsigned int time_sum;
TMBOY 47:9e361da97763 20 unsigned int time_min;
TMBOY 47:9e361da97763 21 unsigned int time_max;
TMBOY 47:9e361da97763 22 unsigned int arg_value;
TMBOY 47:9e361da97763 23 }MeasureValue;
TMBOY 47:9e361da97763 24
TMBOY 47:9e361da97763 25 typedef struct __ListNode{
TMBOY 47:9e361da97763 26 __ListNode *next;
TMBOY 47:9e361da97763 27 //char* Key;
TMBOY 47:9e361da97763 28 std::string Key;
TMBOY 47:9e361da97763 29 MeasureValue Value;
TMBOY 47:9e361da97763 30 }ListNode;
TMBOY 47:9e361da97763 31
TMBOY 47:9e361da97763 32 typedef int (*TimeFuncPtr)(void);
TMBOY 47:9e361da97763 33
TMBOY 47:9e361da97763 34 // this class is not thread-safe
TMBOY 47:9e361da97763 35 class MeasureTimeList{
TMBOY 47:9e361da97763 36 public:
TMBOY 47:9e361da97763 37 static MeasureTimeList* getInstMeasureTime(TimeFuncPtr time_func);
TMBOY 47:9e361da97763 38 //void addMeasureValue(const char* key, int count, int arg_value);
TMBOY 47:9e361da97763 39 void addMeasureValue(const char* key, unsigned int count = 0xffffffff);
TMBOY 47:9e361da97763 40 //void updateMeasureValue(const char* key);
TMBOY 47:9e361da97763 41 void updateMeasureValue(const char* key, unsigned arg_value = 0);
TMBOY 47:9e361da97763 42 void outputResult();
TMBOY 47:9e361da97763 43 void destoryMeasureValueList();
TMBOY 47:9e361da97763 44
TMBOY 47:9e361da97763 45 private:
TMBOY 47:9e361da97763 46 MeasureTimeList(TimeFuncPtr time_func);
TMBOY 47:9e361da97763 47 MeasureTimeList(const MeasureTimeList&);
TMBOY 47:9e361da97763 48 MeasureTimeList& operator=(const MeasureTimeList&);
TMBOY 47:9e361da97763 49 bool searchMeasureValueByKey(const char* key, ListNode* &temp);
TMBOY 47:9e361da97763 50
TMBOY 47:9e361da97763 51 private:
TMBOY 47:9e361da97763 52 static MeasureTimeList* _instance;
TMBOY 47:9e361da97763 53 static TimeFuncPtr _time_func;
TMBOY 47:9e361da97763 54 ListNode* _pListHead;
TMBOY 47:9e361da97763 55 ListNode* _pListTail;
TMBOY 47:9e361da97763 56 // map<const char *, MeasureValue> _map_value;
TMBOY 47:9e361da97763 57 };
TMBOY 47:9e361da97763 58 } //namespace os
TMBOY 47:9e361da97763 59 } //namespace baidu
TMBOY 47:9e361da97763 60 #endif //~__MEASURETIME_H__