|
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | * |
6 | 6 | * Change Logs: |
7 | | - * Date Author Notes |
8 | | - * 2025-07-03 rcitach test case for irq latency |
| 7 | + * Date Author Notes |
| 8 | + * 2025-07-03 rcitach test case for irq latency |
| 9 | + * 2025-11-30 westcity-YOLO Add standardized utest documentation block |
9 | 10 | */ |
10 | 11 |
|
| 12 | +/** |
| 13 | + * Test Case Name: Kernel Core Performance Benchmark Suite |
| 14 | + * |
| 15 | + * Test Objectives: |
| 16 | + * - Measures key kernel performance metrics using high-resolution hardware timer |
| 17 | + * - Validates context switch and IPC mechanism latency |
| 18 | + * - Tests interrupt-to-thread response time (IRQ latency) |
| 19 | + * - Provides quantitative results in microseconds (us) |
| 20 | + * |
| 21 | + * Test Scenarios: |
| 22 | + * - **Context Switch Overhead**: Thread-to-thread switch time |
| 23 | + * - **Semaphore Performance**: rt_sem_take/rt_sem_release round-trip latency |
| 24 | + * - **Event Performance**: rt_event_recv/rt_event_send latency |
| 25 | + * - **Message Queue Performance**: rt_mq_send/rt_mq_recv latency |
| 26 | + * - **Mailbox Performance**: rt_mb_send/rt_mb_recv latency |
| 27 | + * - **IRQ Latency**: Time from hardware timer interrupt to thread wakeup |
| 28 | + * |
| 29 | + * Verification Metrics: |
| 30 | + * - All tests complete without crash or timeout |
| 31 | + * - Measured times are within reasonable system limits (e.g., < 1000 us for IRQ) |
| 32 | + * - Performance data is printed in structured table format |
| 33 | + * - No memory leaks during test execution |
| 34 | + * |
| 35 | + * Dependencies: |
| 36 | + * - RT_USING_PERF_TEST must be enabled |
| 37 | + * - RT_USING_UTEST framework enabled |
| 38 | + * - Hardware timer device named "hwtimer0" (or defined by RT_UTEST_HWTIMER_DEV_NAME) |
| 39 | + * - System must support rt_device_find/open/close for HWTIMER |
| 40 | + * - Sufficient heap memory for dynamic allocation in test runner |
| 41 | + * |
| 42 | + * Expected Results: |
| 43 | + * - Console output shows a formatted table with: |
| 44 | + * Test No | Test Name | Count | Total/Max/Min/Avg Time (us) |
| 45 | + * - Final line: "=== Performance Test Results End ===" |
| 46 | + * - utest framework reports: [ PASSED ] [ result ] testcase (core.perf_test) |
| 47 | + * - Test runs via: `utest_run core.perf_test` in msh |
| 48 | + */ |
| 49 | + |
| 50 | + |
11 | 51 | #include <rtthread.h> |
12 | 52 | #include <rtdevice.h> |
13 | 53 | #include <rtservice.h> |
|
0 commit comments