zephyr/tests/benchmarks/latency_measure
Anas Nashif 3b00571160 tests: benchmarks: record benchmark results
Record benchmark results into a CSV file that can be used for tracking.
The data will be available in recording.csv in the build directory.

For example:

cat recording.csv

metric,cycles,nanoseconds
Average thread context switch using yield,11654,11654
Average context switch time between threads (coop),21149,21149
Switch from ISR back to interrupted thread,4928,4927
Time from ISR to executing a different thread,3872,3871
Time to create a thread (without start),4224,4223
Time to start a thread,10784,10783
Time to suspend a thread,10400,10399
Time to resume a thread,10688,10687
Time to abort a thread (not running),1536,1535
Average semaphore signal time,3424,3424
Average semaphore test time,1344,1344
Semaphore take time (context switch),12736,12735
Semaphore give time (context switch),17568,17567
Average time to lock a mutex,1632,1632
Average time to unlock a mutex,4738,4738

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 23:48:28 -04:00
..
boards
src
CMakeLists.txt
README.rst
prj.conf
testcase.yaml

README.rst

Latency Measurements
####################

This benchmark measures the latency of selected kernel capabilities, including:


* Measure time to switch from ISR back to interrupted thread
* Measure time from ISR to executing a different thread (rescheduled)
* Measure average time to signal a semaphore then test that semaphore
* Measure average time to signal a semaphore then test that semaphore with a context switch
* Measure average time to lock a mutex then unlock that mutex
* Measure average context switch time between threads using (k_yield)
* Measure average context switch time between threads (coop)
* Time it takes to suspend a thread
* Time it takes to resume a suspended thread
* Time it takes to create a new thread (without starting it)
* Time it takes to start a newly created thread


Sample output of the benchmark::

        *** Booting Zephyr OS build zephyr-v2.3.0-2257-g0f420483db07  ***
        START - Time Measurement
        Timing results: Clock frequency: 120 MHz
        Average thread context switch using yield                   :     420 cycles ,     3502 ns
        Average context switch time between threads (coop)          :     429 cycles ,     3583 ns
        Switch from ISR back to interrupted thread                  :     670 cycles ,     5583 ns
        Time from ISR to executing a different thread               :     570 cycles ,     4750 ns
        Time to create a thread (without start)                     :     360 cycles ,     3000 ns
        Time to start a thread                                      :     545 cycles ,     4541 ns
        Time to suspend a thread                                    :     605 cycles ,     5041 ns
        Time to resume a thread                                     :     660 cycles ,     5500 ns
        Time to abort a thread (not running)                        :     495 cycles ,     4125 ns
        Average semaphore signal time                               :     195 cycles ,     1626 ns
        Average semaphore test time                                 :      62 cycles ,      518 ns
        Semaphore take time (context switch)                        :     695 cycles ,     5791 ns
        Semaphore give time (context switch)                        :     845 cycles ,     7041 ns
        Average time to lock a mutex                                :      79 cycles ,      659 ns
        Average time to unlock a mutex                              :     370 cycles ,     3085 ns
        ===================================================================
        PROJECT EXECUTION SUCCESSFUL