ex
Fork of mbed-os-example-mbed5-blinky by
Diff: DuerOS-Light-SDK-v1.1.0/duer-os-light/src/utility/baidu_measure_time.h
- Revision:
- 47:9e361da97763
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DuerOS-Light-SDK-v1.1.0/duer-os-light/src/utility/baidu_measure_time.h Tue Jul 18 16:54:45 2017 +0800
@@ -0,0 +1,45 @@
+#ifndef __MEASURETIME_H__
+#define __MEASURETIME_H__
+#include "us_ticker_api.h"
+
+#define ArraySize 20
+
+#define print_error printf
+
+namespace baidu{
+namespace os{
+
+typedef struct __MeasureValue{
+ unsigned int total_cnt;
+ unsigned int cur_cnt;
+ unsigned int time_begin;
+ unsigned int time_sum;
+ unsigned int time_min;
+ unsigned int time_max;
+ unsigned int arg_value;
+}MeasureValue;
+
+typedef unsigned int (*TimeFuncPtr)(void);
+
+// this class is not thread-safe
+class MeasureTime{
+public:
+ static MeasureTime* getInstMeasureTime(TimeFuncPtr time_func);
+ void addMeasureValue(int key, int count);
+ void updateMeasureValue(int key, int arg_value, int continuous_measure_flag);
+ void outputResult();
+
+private:
+ MeasureTime(TimeFuncPtr time_func);
+ MeasureTime(const MeasureTime&);
+ MeasureTime& operator=(const MeasureTime&);
+
+private:
+ static MeasureTime* _instance;
+ static TimeFuncPtr _time_func;
+ MeasureValue MeasureArray[ArraySize];
+};
+
+} //namespace os
+} //namespace baidu
+#endif //~__MEASURETIME_H__
