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 __BAIDU_TIME_CALCULATE_H__
TMBOY 47:9e361da97763 2 #define __BAIDU_TIME_CALCULATE_H__
TMBOY 47:9e361da97763 3
TMBOY 47:9e361da97763 4 #ifdef __cplusplus
TMBOY 47:9e361da97763 5 extern "C" {
TMBOY 47:9e361da97763 6 #endif
TMBOY 47:9e361da97763 7
TMBOY 47:9e361da97763 8 void add_measure_value(int key, int count);
TMBOY 47:9e361da97763 9 void update_measure_value(int key, int arg_value, int continuous_measure_flag);
TMBOY 47:9e361da97763 10 void output_measure_result();
TMBOY 47:9e361da97763 11
TMBOY 47:9e361da97763 12 //**************************************************************************************//
TMBOY 47:9e361da97763 13 // KEY is number from 0 to 9, because the macor ArraySize is 10. You can enlarge it if you calcute more than 10 sites.
TMBOY 47:9e361da97763 14 // COUNTER is the biggest measurement times.
TMBOY 47:9e361da97763 15 // ARGUEMENT is used for speed as ARGUEMENT/TIME_AVERAGE.
TMBOY 47:9e361da97763 16 //
TMBOY 47:9e361da97763 17 // !!!!!! Take carefull: KEY in TIME_BEGIN and TIME_END must be the same. !!!!!!
TMBOY 47:9e361da97763 18 //
TMBOY 47:9e361da97763 19 // TIME_BEGIN(1, 10);
TMBOY 47:9e361da97763 20 // printf("ABC");
TMBOY 47:9e361da97763 21 // TIME_END(1, 200, UNCONTINUOUS_TIME_MEASURE);
TMBOY 47:9e361da97763 22 //
TMBOY 47:9e361da97763 23 // You can call TIME_RESULT() anywhere to print the resutl.
TMBOY 47:9e361da97763 24 //
TMBOY 47:9e361da97763 25 //**************************************************************************************//
TMBOY 47:9e361da97763 26
TMBOY 47:9e361da97763 27 enum baidu_time_measure_params {
TMBOY 47:9e361da97763 28 // TIME_END will measure time no matter there is a one-to-one TIME_BEGIN or not
TMBOY 47:9e361da97763 29 CONTINUOUS_TIME_MEASURE = 0,
TMBOY 47:9e361da97763 30 // TIME_END will measure time only when there is a one-to-one TIME_BEGIN
TMBOY 47:9e361da97763 31 UNCONTINUOUS_TIME_MEASURE = 1,
TMBOY 47:9e361da97763 32 MAX_TIME_CALCULATE_COUNT = 0X7FFFFFFF,
TMBOY 47:9e361da97763 33 };
TMBOY 47:9e361da97763 34
TMBOY 47:9e361da97763 35 #define TIME_BEGIN(KEY, COUNTER) do{\
TMBOY 47:9e361da97763 36 add_measure_value(KEY, COUNTER);\
TMBOY 47:9e361da97763 37 }while(0)
TMBOY 47:9e361da97763 38
TMBOY 47:9e361da97763 39 #define TIME_END(KEY, ARGUEMENT, FLAG) do{\
TMBOY 47:9e361da97763 40 update_measure_value(KEY, ARGUEMENT, FLAG);\
TMBOY 47:9e361da97763 41 }while(0)
TMBOY 47:9e361da97763 42
TMBOY 47:9e361da97763 43 #define TIME_RESULT() do{\
TMBOY 47:9e361da97763 44 output_measure_result();\
TMBOY 47:9e361da97763 45 }while(0)
TMBOY 47:9e361da97763 46
TMBOY 47:9e361da97763 47 //#define BAIDU_PERFORM_STATISTIC
TMBOY 47:9e361da97763 48
TMBOY 47:9e361da97763 49 enum baidu_perform_statistic_watch_point {
TMBOY 47:9e361da97763 50 PERFORM_STATISTIC_START_RECORD = 1, // from user press start button to start record
TMBOY 47:9e361da97763 51 PERFORM_STATISTIC_RECORDER_ON_DATA, // time consume of encode and send record data
TMBOY 47:9e361da97763 52 PERFORM_STATISTIC_READ_VOICE_DATA, // time consume of read voice data from arm
TMBOY 47:9e361da97763 53 PERFORM_STATISTIC_SOTP_RECORD, // from user stop record to the recorder thread stop
TMBOY 47:9e361da97763 54 PERFORM_STATISTIC_BASE64_ENCODE, // the time consume of mbedtls_base64_encode
TMBOY 47:9e361da97763 55 PERFORM_STATISTIC_GET_URL, // the time from user stop record to get media data from URL
TMBOY 47:9e361da97763 56 // time consume of recorder_output_handler(encode and pass to CA)
TMBOY 47:9e361da97763 57 PERFORM_STATISTIC_OUTPUT_RECORDER_DATA,
TMBOY 47:9e361da97763 58 // time consume of bdspx_speex_encode encode data(exclude output encoded data)
TMBOY 47:9e361da97763 59 PERFORM_STATISTIC_SPEEX_ENCODE,
TMBOY 47:9e361da97763 60 PERFORM_STATISTIC_GET_MEDIA_BY_URL, // time consume from get media data from url to play it
TMBOY 47:9e361da97763 61 PERFORM_STATISTIC_PLAY_URL_MEDIA, // time consume of mdm_media_data_out_handler(play url data)
TMBOY 47:9e361da97763 62 PERFORM_STATISTIC_GET_MEDIA_BY_PATH, // time consume of read local media
TMBOY 47:9e361da97763 63 PERFORM_STATISTIC_PLAY_LOCAL_MEDIA, // time consume of mdm_media_data_out_handler(play local data)
TMBOY 47:9e361da97763 64 };
TMBOY 47:9e361da97763 65
TMBOY 47:9e361da97763 66 #ifdef BAIDU_PERFORM_STATISTIC
TMBOY 47:9e361da97763 67 #define PERFORM_STATISTIC_BEGIN(KEY, COUNTER) TIME_BEGIN(KEY, COUNTER)
TMBOY 47:9e361da97763 68 #define PERFORM_STATISTIC_END(KEY, ARGUEMENT, FLAG) TIME_END(KEY, ARGUEMENT, FLAG)
TMBOY 47:9e361da97763 69 #define PERFORM_STATISTIC_RESULT() TIME_RESULT()
TMBOY 47:9e361da97763 70 #else
TMBOY 47:9e361da97763 71 #define PERFORM_STATISTIC_BEGIN(KEY, COUNTER)
TMBOY 47:9e361da97763 72 #define PERFORM_STATISTIC_END(KEY, ARGUEMENT, FLAG)
TMBOY 47:9e361da97763 73 #define PERFORM_STATISTIC_RESULT()
TMBOY 47:9e361da97763 74 #endif
TMBOY 47:9e361da97763 75
TMBOY 47:9e361da97763 76 #ifdef __cplusplus
TMBOY 47:9e361da97763 77 }
TMBOY 47:9e361da97763 78 #endif
TMBOY 47:9e361da97763 79
TMBOY 47:9e361da97763 80 #endif //~__BAIDU_TIME_CALCULATE_H__