1 /* 2 * Copyright (c) 2006-2025, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2025-07-03 rcitach test case 9 */ 10 11 #ifndef PERF_TC_H__ 12 #define PERF_TC_H__ 13 14 #include <rtthread.h> 15 #include <rtdevice.h> 16 #include <rtservice.h> 17 #include <rttypes.h> 18 19 #define THREAD_STACK_SIZE 2048 20 #define THREAD_PRIORITY 10 21 #define THREAD_TIMESLICE 5 22 typedef struct rt_perf 23 { 24 char name[64]; 25 volatile rt_uint32_t begin_time; 26 volatile rt_uint32_t real_time; 27 volatile rt_uint32_t tot_time; 28 volatile rt_uint32_t max_time; 29 volatile rt_uint32_t min_time; 30 volatile rt_uint32_t count; 31 volatile double avg_time; 32 volatile rt_uint32_t tmp_time; /* Temporary data */ 33 rt_mutex_t lock; 34 void (*local_modify)(struct rt_perf *perf); 35 rt_bool_t dump_head; 36 } rt_perf_t; 37 38 void rt_perf_start_impl(rt_perf_t *perf, rt_hwtimerval_t *timeout); 39 void rt_perf_stop(rt_perf_t *perf); 40 void rt_perf_dump( rt_perf_t *perf); 41 rt_perf_start(rt_perf_t * perf)42static inline void rt_perf_start(rt_perf_t *perf) 43 { 44 rt_perf_start_impl(perf, RT_NULL); 45 } 46 47 rt_err_t context_switch_test(rt_perf_t *perf); 48 rt_err_t rt_perf_irq_latency(rt_perf_t *perf); 49 rt_err_t rt_perf_thread_sem(rt_perf_t *perf); 50 rt_err_t rt_perf_thread_event(rt_perf_t *perf); 51 rt_err_t rt_perf_thread_mq(rt_perf_t *perf); 52 rt_err_t rt_perf_thread_mbox(rt_perf_t *perf); 53 54 #endif /* PERF_TC_H__ */ 55 56