| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- /******************************************************************************
- 版权所有:
- 文件名称: rt_stat.h
- 文件版本: 01.01
- 创建作者: sunxi
- 创建日期: 2020-06-18
- 功能说明:
- 其它说明:
- 修改记录:
- */
- #ifndef _RT_STAT_H
- #define _RT_STAT_H
- /*------------------------------- 头文件 --------------------------------------
- */
- /*------------------------------- 宏定义 --------------------------------------
- */
- #define RT_STAT_OTHER_NUM 8
- #define RT_STAT_BIG_LOOP 0
- /*------------------------------ 类型结构 -------------------------------------
- */
- struct rt_stat
- {
- const char * name;
- unsigned long min;
- unsigned long max;
- unsigned long sum;
- unsigned long cnt;
- };
- /*------------------------------ 函数声明 -------------------------------------
- */
- extern struct rt_stat g_stat_other[8];
- static inline void rt_stat_init(struct rt_stat *stat,const char *name)
- {
- stat->name = name;
- stat->cnt = 0;
- stat->sum = 0;
- stat->max = 0;
- stat->min = -1;
- }
- static inline void rt_stat_in(struct rt_stat *stat,unsigned long n)
- {
- stat->cnt++;
- stat->sum += n;
- if(n < stat->min)
- {
- stat->min = n;
- }
- if(n > stat->max)
- {
- stat->max = n;
- }
- }
- static inline void rt_stat_other_init(int index,const char *name)
- {
- struct rt_stat *stat = &g_stat_other[index];
-
- stat->name = name;
- stat->cnt = 0;
- stat->sum = 0;
- stat->max = 0;
- stat->min = -1;
- }
- static inline void rt_stat_other_in(int index,unsigned long n)
- {
- struct rt_stat *stat = &g_stat_other[index];
- stat->cnt++;
- stat->sum += n;
- if(n < stat->min)
- {
- stat->min = n;
- }
- if(n > stat->max)
- {
- stat->max = n;
- }
- }
- static inline void rt_stat_printf(struct rt_stat *stat)
- {
- unsigned long avg = 0;
-
- if(stat->cnt)
- {
- avg = stat->sum/stat->cnt;
- }
- rt_printf("%-24s%ld\t%ld\t%ld\t%-016ld%ld\r\n",stat->name,stat->min,stat->max,avg,stat->sum,stat->cnt);
- }
- void rt_stat_printf_q16(struct rt_stat *stat);
- int rt_stat_other_reset(void);
- int rt_stat_other_printf(void);
-
- #endif //_RT_STAT_H
- /*------------------------------ 文件结束 -------------------------------------
- */
|