summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2018-12-11 18:16:04 +0600
committerzhengchao <[email protected]>2018-12-11 18:16:04 +0600
commit2a2abf7f482d1bc65477e4d34327e85cfb47e1ee (patch)
tree70eb563eb308ae5f3c873b58f51d8bf409bc3fed /inc
parent23ae669c44584c8e64b555e243072567e595a708 (diff)
在fieldstat.h中,提供clock_gettime的封装
Diffstat (limited to 'inc')
-rw-r--r--inc/field_stat2.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/inc/field_stat2.h b/inc/field_stat2.h
index 97e791e..90f3a76 100644
--- a/inc/field_stat2.h
+++ b/inc/field_stat2.h
@@ -1,7 +1,7 @@
#ifndef H_SCREEN_STAT_H_INCLUDE
#define H_SCREEN_STAT_H_INCLUDE
#include <stdio.h>
-
+#include <time.h>
#ifndef __cplusplus
#error("This file should be compiled with C++ compiler")
#endif
@@ -68,6 +68,19 @@ int FS_register(screen_stat_handle_t handle,enum field_dsp_style_t style,enum fi
//scaling: negative value: zoom in; positive value: zoom out;
int FS_register_ratio(screen_stat_handle_t handle,int numerator_id,int denominator_id,int scaling,enum field_dsp_style_t style,enum field_calc_algo calc_type,const char* name);
+inline void record_time_start(struct timespec *start)
+{
+ clock_gettime(CLOCK_MONOTONIC, start);
+}
+inline long record_time_elapse_us(struct timespec *start)
+{
+ struct timespec end;
+ long elapsed = 0;
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ elapsed = (end.tv_sec - start->tv_sec)*1000000 + (end.tv_nsec - start->tv_nsec)/1000;
+ return elapsed;
+}
+
//@param bins format is comma spited number, e.g."0.1,0.5,0.8,0.9,0.95,0.99"
//return 0 on success, <0 on failed.
int FS_histogram_set_bins(screen_stat_handle_t handle, int id, const char* bins);