| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /******************************************************************************
- 版权所有:
- 文件名称: rt_stat.c
- 文件版本: 01.01
- 创建作者: sunxi
- 创建日期: 2020-06-18
- 功能说明: 实时统计。
- 其它说明:
- 修改记录:
- */
- /*------------------------------- 头文件 --------------------------------------
- */
- #include "rt.h"
- /*------------------------------- 宏定义 --------------------------------------
- */
- /*------------------------------ 类型结构 -------------------------------------
- */
- /*------------------------------ 全局变量 -------------------------------------
- */
- struct rt_stat g_stat_other[RT_STAT_OTHER_NUM] =
- {
- {"other0", -1, 0, 0, 0},
- {"other1", -1, 0, 0, 0},
- {"other2", -1, 0, 0, 0},
- {"other3", -1, 0, 0, 0},
- {"other4", -1, 0, 0, 0},
- {"other5", -1, 0, 0, 0},
- {"other6", -1, 0, 0, 0},
- {"other7", -1, 0, 0, 0},
- };
- /*------------------------------ 函数声明 -------------------------------------
- */
- /*------------------------------ 外部函数 -------------------------------------
- 外部函数供其它实体文件引用,必须仔细检查传入参数的合法性.
- */
- static char * q16_to_str(long q16)
- {
- static char str[32];
- sprintf(str,"%f",(float)q16/Q16_BASE);
- return str;
- }
- void rt_stat_printf_q16(struct rt_stat *stat)
- {
- unsigned long avg = 0;
-
- if(stat->cnt)
- {
- avg = stat->sum/stat->cnt;
- }
- rt_printf("%-24s",stat->name);
- rt_printf("%s\t",q16_to_str((long)stat->min));
- rt_printf("%s\t",q16_to_str((long)stat->max));
- rt_printf("%s\t",q16_to_str((long)avg));
- rt_printf("%-16lu%lu\r\n",stat->sum,stat->cnt);
- return;
- }
- int rt_stat_other_reset(void)
- {
- int i;
-
-
- for(i=0; i<RT_STAT_OTHER_NUM; i++)
- {
- rt_stat_init(&g_stat_other[i],g_stat_other[i].name);
- }
- return 0;
- }
- int rt_stat_other_printf(void)
- {
- int i;
-
- rt_printf("\r\n[其它时间统计(单位:us)]\r\n");
-
- for(i=0; i<RT_STAT_OTHER_NUM; i++)
- {
- rt_stat_printf(&g_stat_other[i]);
- }
- return 0;
- }
- /*------------------------------ 内部函数 -------------------------------------
- 内部函数以下划线‘_’开头,不需要检查参数的合法性.
- */
- /*------------------------------ 测试函数 -------------------------------------
- 一个实体文件必须带一个本模块的测试函数来进行单元测试,如果的确不方便在本模块中
- 进行单元测试,必须在此注明实际的测试位置(例如在哪个实体文件中使用哪个测试函数).
- */
- /*------------------------------ 文件结束 -------------------------------------
- */
|