Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/src/utility/baidu_measure_time.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | #ifndef __MEASURETIME_H__ |
| TMBOY | 47:9e361da97763 | 2 | #define __MEASURETIME_H__ |
| TMBOY | 47:9e361da97763 | 3 | #include "us_ticker_api.h" |
| TMBOY | 47:9e361da97763 | 4 | |
| TMBOY | 47:9e361da97763 | 5 | #define ArraySize 20 |
| TMBOY | 47:9e361da97763 | 6 | |
| TMBOY | 47:9e361da97763 | 7 | #define print_error printf |
| TMBOY | 47:9e361da97763 | 8 | |
| TMBOY | 47:9e361da97763 | 9 | namespace baidu{ |
| TMBOY | 47:9e361da97763 | 10 | namespace os{ |
| TMBOY | 47:9e361da97763 | 11 | |
| TMBOY | 47:9e361da97763 | 12 | typedef struct __MeasureValue{ |
| TMBOY | 47:9e361da97763 | 13 | unsigned int total_cnt; |
| TMBOY | 47:9e361da97763 | 14 | unsigned int cur_cnt; |
| TMBOY | 47:9e361da97763 | 15 | unsigned int time_begin; |
| TMBOY | 47:9e361da97763 | 16 | unsigned int time_sum; |
| TMBOY | 47:9e361da97763 | 17 | unsigned int time_min; |
| TMBOY | 47:9e361da97763 | 18 | unsigned int time_max; |
| TMBOY | 47:9e361da97763 | 19 | unsigned int arg_value; |
| TMBOY | 47:9e361da97763 | 20 | }MeasureValue; |
| TMBOY | 47:9e361da97763 | 21 | |
| TMBOY | 47:9e361da97763 | 22 | typedef unsigned int (*TimeFuncPtr)(void); |
| TMBOY | 47:9e361da97763 | 23 | |
| TMBOY | 47:9e361da97763 | 24 | // this class is not thread-safe |
| TMBOY | 47:9e361da97763 | 25 | class MeasureTime{ |
| TMBOY | 47:9e361da97763 | 26 | public: |
| TMBOY | 47:9e361da97763 | 27 | static MeasureTime* getInstMeasureTime(TimeFuncPtr time_func); |
| TMBOY | 47:9e361da97763 | 28 | void addMeasureValue(int key, int count); |
| TMBOY | 47:9e361da97763 | 29 | void updateMeasureValue(int key, int arg_value, int continuous_measure_flag); |
| TMBOY | 47:9e361da97763 | 30 | void outputResult(); |
| TMBOY | 47:9e361da97763 | 31 | |
| TMBOY | 47:9e361da97763 | 32 | private: |
| TMBOY | 47:9e361da97763 | 33 | MeasureTime(TimeFuncPtr time_func); |
| TMBOY | 47:9e361da97763 | 34 | MeasureTime(const MeasureTime&); |
| TMBOY | 47:9e361da97763 | 35 | MeasureTime& operator=(const MeasureTime&); |
| TMBOY | 47:9e361da97763 | 36 | |
| TMBOY | 47:9e361da97763 | 37 | private: |
| TMBOY | 47:9e361da97763 | 38 | static MeasureTime* _instance; |
| TMBOY | 47:9e361da97763 | 39 | static TimeFuncPtr _time_func; |
| TMBOY | 47:9e361da97763 | 40 | MeasureValue MeasureArray[ArraySize]; |
| TMBOY | 47:9e361da97763 | 41 | }; |
| TMBOY | 47:9e361da97763 | 42 | |
| TMBOY | 47:9e361da97763 | 43 | } //namespace os |
| TMBOY | 47:9e361da97763 | 44 | } //namespace baidu |
| TMBOY | 47:9e361da97763 | 45 | #endif //~__MEASURETIME_H__ |
