perf_tc.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef PERF_TC_H__
  11. #define PERF_TC_H__
  12. #include <rtthread.h>
  13. #include <rtdevice.h>
  14. #include <rtservice.h>
  15. #include <rttypes.h>
  16. #define THREAD_STACK_SIZE 2048
  17. #define THREAD_PRIORITY 10
  18. #define THREAD_TIMESLICE 5
  19. typedef struct rt_perf
  20. {
  21. char name[64];
  22. volatile rt_uint32_t begin_time;
  23. volatile rt_uint32_t real_time;
  24. volatile rt_uint32_t tot_time;
  25. volatile rt_uint32_t max_time;
  26. volatile rt_uint32_t min_time;
  27. volatile rt_uint32_t count;
  28. volatile double avg_time;
  29. volatile rt_uint32_t tmp_time; /* Temporary data */
  30. rt_mutex_t lock;
  31. void (*local_modify)(struct rt_perf *perf);
  32. rt_bool_t dump_head;
  33. } rt_perf_t;
  34. void rt_perf_start_impl(rt_perf_t *perf, rt_hwtimerval_t *timeout);
  35. void rt_perf_stop(rt_perf_t *perf);
  36. void rt_perf_dump( rt_perf_t *perf);
  37. static inline void rt_perf_start(rt_perf_t *perf)
  38. {
  39. rt_perf_start_impl(perf, RT_NULL);
  40. }
  41. rt_err_t context_switch_test(rt_perf_t *perf);
  42. rt_err_t rt_perf_irq_latency(rt_perf_t *perf);
  43. rt_err_t rt_perf_thread_sem(rt_perf_t *perf);
  44. rt_err_t rt_perf_thread_event(rt_perf_t *perf);
  45. rt_err_t rt_perf_thread_mq(rt_perf_t *perf);
  46. rt_err_t rt_perf_thread_mbox(rt_perf_t *perf);
  47. #endif /* PERF_TC_H__ */