diff options
| author | Chen Wang <[email protected]> | 2025-10-11 16:07:08 +0800 |
|---|---|---|
| committer | R b b666 <[email protected]> | 2025-10-11 18:24:40 +0800 |
| commit | 74997901401df476d4b73b34ea3de945916a904f (patch) | |
| tree | 1b7bd672dc0ca6fef0322444f0397df3be7ab94e /src/utest/perf/perf_tc.h | |
| parent | 66448d9e96ffd3a6747bb2350113de3626d9a2f1 (diff) | |
utest: core: move perf testcase from example to src
Also:
- Add "RT_" prefix for the UTEST config options.
- Follow the naming rules to update the case name.
Signed-off-by: Chen Wang <[email protected]>
Diffstat (limited to 'src/utest/perf/perf_tc.h')
| -rw-r--r-- | src/utest/perf/perf_tc.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/utest/perf/perf_tc.h b/src/utest/perf/perf_tc.h new file mode 100644 index 0000000000..06aeb5214e --- /dev/null +++ b/src/utest/perf/perf_tc.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2006-2025, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-07-03 rcitach test case + */ + +#ifndef PERF_TC_H__ +#define PERF_TC_H__ + +#include <rtthread.h> +#include <rtdevice.h> +#include <rtservice.h> +#include <rttypes.h> + +#define THREAD_STACK_SIZE 2048 +#define THREAD_PRIORITY 10 +#define THREAD_TIMESLICE 5 +typedef struct rt_perf +{ + char name[64]; + volatile rt_uint32_t begin_time; + volatile rt_uint32_t real_time; + volatile rt_uint32_t tot_time; + volatile rt_uint32_t max_time; + volatile rt_uint32_t min_time; + volatile rt_uint32_t count; + volatile double avg_time; + volatile rt_uint32_t tmp_time; /* Temporary data */ + rt_mutex_t lock; + void (*local_modify)(struct rt_perf *perf); + rt_bool_t dump_head; +} rt_perf_t; + +void rt_perf_start_impl(rt_perf_t *perf, rt_hwtimerval_t *timeout); +void rt_perf_stop(rt_perf_t *perf); +void rt_perf_dump( rt_perf_t *perf); + +static inline void rt_perf_start(rt_perf_t *perf) +{ + rt_perf_start_impl(perf, RT_NULL); +} + +rt_err_t context_switch_test(rt_perf_t *perf); +rt_err_t rt_perf_irq_latency(rt_perf_t *perf); +rt_err_t rt_perf_thread_sem(rt_perf_t *perf); +rt_err_t rt_perf_thread_event(rt_perf_t *perf); +rt_err_t rt_perf_thread_mq(rt_perf_t *perf); +rt_err_t rt_perf_thread_mbox(rt_perf_t *perf); + +#endif /* PERF_TC_H__ */ + |
