Skip to content

Conversation

@hujun260
Copy link
Contributor

@hujun260 hujun260 commented Feb 1, 2026

Summary

This PR introduces perf_gettime_test(), a new test module for validating up_perf_gettime() performance counter functionality. The changes add a complete test implementation with 5 independent test cases that verify performance event counter behavior:

  1. Initial time value acquisition and validation
  2. Monotonically increasing time verification with 10 iterations
  3. Time interval statistics collection and analysis
  4. Performance counter frequency validation
  5. Rapid consecutive call verification for high-frequency access patterns

The test implementation follows NuttX ostest coding standards with conditional compilation support for CONFIG_ARCH_HAVE_PERF_EVENTS.

Impact

• Functionality: Enables comprehensive testing of performance event counters across supported architectures
• Coverage: Adds 5 detailed test cases covering initialization, monotonicity, statistics, frequency, and rapid access patterns
• Quality: Includes complete error handling with assertion verification points and detailed output reporting
• Standards: Follows Apache-2.0 license format and NuttX ostest coding conventions

Testing

Test Environment:

qemu-armv7r:nsh
CONFIG_ARCH_PERF_EVENTS=y
CONFIG_PERF_OVERFLOW_CORRECTION=y
CONFIG_SYSTEM_TIME64=y

perf_gettime_test: Starting performance event test

Test 1: Getting initial performance time value
perf_gettime_test: Initial time = 1772431887

Test 2: Verify monotonically increasing time values
perf_gettime_test [0]: current=1873341545, interval=100909658
perf_gettime_test [1]: current=1974284158, interval=100942613
perf_gettime_test [2]: current=2075294261, interval=101010103
perf_gettime_test [3]: current=2176282297, interval=100988036
perf_gettime_test [4]: current=2277330625, interval=101048328
perf_gettime_test [5]: current=2378329244, interval=100998619
perf_gettime_test [6]: current=2479337636, interval=101008392
perf_gettime_test [7]: current=2580385082, interval=101047446
perf_gettime_test [8]: current=2681285935, interval=100900853
perf_gettime_test [9]: current=2782287337, interval=101001402

Test 3: Analyzing time intervals
perf_gettime_test: Interval statistics:
  Minimum interval: 100900853
  Maximum interval: 101048328
  Average interval: 100985545
  Total iterations: 10
perf_gettime_test: Time intervals look reasonable

Test 4: Getting performance counter frequency
perf_gettime_test: Performance frequency = 1000000000 Hz
perf_gettime_test: Performance frequency is valid

Test 5: Testing multiple rapid calls
perf_gettime_test: Rapid call 1: 2784078889
perf_gettime_test: Rapid call 2: 2784224923
perf_gettime_test: Rapid call 3: 2784390465
perf_gettime_test: Rapid call 4: 2784523721
perf_gettime_test: Rapid call 5: 2784620879
perf_gettime_test: Rapid call 6: 2784718050

perf_gettime_test: All performance event tests PASSED

@hujun260 hujun260 marked this pull request as draft February 1, 2026 07:24
@hujun260 hujun260 force-pushed the apache_perf_test branch 3 times, most recently from fcf79de to 6bde8fa Compare February 1, 2026 07:29
@hujun260 hujun260 marked this pull request as ready for review February 1, 2026 07:31
@hujun260 hujun260 force-pushed the apache_perf_test branch 2 times, most recently from ee25414 to cffd9c2 Compare February 2, 2026 00:55
Integrate up_perf_gettime() test into ostest suite with comprehensive
test coverage including monotonicity verification, interval statistics,
and frequency validation. The test verifies performance event counter
functionality across 5 independent test cases with proper error handling.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hujun260 :-) Lets just wait for the CI build :-)

@xiaoxiang781216 xiaoxiang781216 merged commit b2d4ad6 into apache:master Feb 2, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants