ex

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers baidu_measure_time_list.h Source File

baidu_measure_time_list.h

00001 #ifndef __MEASURETIME_H__
00002 #define __MEASURETIME_H__
00003 
00004 #include <string>
00005 #include <map>
00006 #include <stdio.h>
00007 
00008 #define print_error printf
00009 
00010 int time_current_get(void);
00011 
00012 namespace baidu{
00013 namespace os{
00014 
00015 typedef struct __MeasureValue{
00016     unsigned int total_cnt;
00017     unsigned int cur_cnt;
00018     unsigned int time_begin;
00019     unsigned int time_sum;
00020     unsigned int time_min;
00021     unsigned int time_max;
00022     unsigned int arg_value;
00023 }MeasureValue;
00024 
00025 typedef struct __ListNode{
00026     __ListNode *next;
00027     //char* Key;
00028     std::string Key;
00029     MeasureValue Value;
00030 }ListNode;
00031 
00032 typedef int (*TimeFuncPtr)(void);
00033 
00034 // this class is not thread-safe
00035 class MeasureTimeList{
00036 public:
00037     static MeasureTimeList* getInstMeasureTime(TimeFuncPtr time_func);
00038     //void addMeasureValue(const char* key, int count, int arg_value);
00039     void addMeasureValue(const char* key, unsigned int count = 0xffffffff);
00040     //void updateMeasureValue(const char* key);
00041     void updateMeasureValue(const char* key, unsigned arg_value = 0);
00042     void outputResult();
00043     void destoryMeasureValueList();
00044 
00045 private:
00046     MeasureTimeList(TimeFuncPtr time_func);
00047     MeasureTimeList(const MeasureTimeList&);
00048     MeasureTimeList& operator=(const MeasureTimeList&);
00049     bool searchMeasureValueByKey(const char* key, ListNode* &temp);
00050     
00051 private:
00052     static MeasureTimeList* _instance;
00053     static TimeFuncPtr _time_func;
00054     ListNode* _pListHead;
00055     ListNode* _pListTail;
00056 //  map<const char *, MeasureValue> _map_value;
00057 };
00058 } //namespace os
00059 } //namespace baidu
00060 #endif //~__MEASURETIME_H__