Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Timing Measurement APIs

Timing Measurement APIs . More...

Topics

 Arch specific Timing Measurement APIs
 Arch specific Timing Measurement APIs .
 
 Board specific Timing Measurement APIs
 Board specific Timing Measurement APIs .
 
 SoC specific Timing Measurement APIs
 SoC specific Timing Measurement APIs .
 

Functions

void timing_init (void)
 Initialize the timing subsystem.
 
void timing_start (void)
 Signal the start of the timing information gathering.
 
void timing_stop (void)
 Signal the end of the timing information gathering.
 
static timing_t timing_counter_get (void)
 Return timing counter.
 
static uint64_t timing_cycles_get (volatile timing_t *const start, volatile timing_t *const end)
 Get number of cycles between start and end.
 
static uint64_t timing_freq_get (void)
 Get frequency of counter used (in Hz).
 
static uint64_t timing_cycles_to_ns (uint64_t cycles)
 Convert number of cycles into nanoseconds.
 
static uint64_t timing_cycles_to_ns_avg (uint64_t cycles, uint32_t count)
 Convert number of cycles into nanoseconds with averaging.
 
static uint32_t timing_freq_get_mhz (void)
 Get frequency of counter used (in MHz).
 

Detailed Description

Timing Measurement APIs .

The timing measurement APIs can be used to obtain execution time of a section of code to aid in analysis and optimization.

Please note that the timing functions may use a different timer than the default kernel timer, where the timer being used is specified by architecture, SoC or board configuration.

Function Documentation

◆ timing_counter_get()

static timing_t timing_counter_get ( void )
inlinestatic

#include <zephyr/timing/timing.h>

Return timing counter.

Returns
Timing counter.

◆ timing_cycles_get()

static uint64_t timing_cycles_get ( volatile timing_t *const start,
volatile timing_t *const end )
inlinestatic

#include <zephyr/timing/timing.h>

Get number of cycles between start and end.

For some architectures or SoCs, the raw numbers from counter need to be scaled to obtain actual number of cycles.

Parameters
startPointer to counter at start of a measured execution.
endPointer to counter at stop of a measured execution.
Returns
Number of cycles between start and end.

◆ timing_cycles_to_ns()

static uint64_t timing_cycles_to_ns ( uint64_t cycles)
inlinestatic

#include <zephyr/timing/timing.h>

Convert number of cycles into nanoseconds.

Parameters
cyclesNumber of cycles
Returns
Converted time value

◆ timing_cycles_to_ns_avg()

static uint64_t timing_cycles_to_ns_avg ( uint64_t cycles,
uint32_t count )
inlinestatic

#include <zephyr/timing/timing.h>

Convert number of cycles into nanoseconds with averaging.

Parameters
cyclesNumber of cycles
countTimes of accumulated cycles to average over
Returns
Converted time value

◆ timing_freq_get()

static uint64_t timing_freq_get ( void )
inlinestatic

#include <zephyr/timing/timing.h>

Get frequency of counter used (in Hz).

Returns
Frequency of counter used for timing in Hz.

◆ timing_freq_get_mhz()

static uint32_t timing_freq_get_mhz ( void )
inlinestatic

#include <zephyr/timing/timing.h>

Get frequency of counter used (in MHz).

Returns
Frequency of counter used for timing in MHz.

◆ timing_init()

void timing_init ( void )

#include <zephyr/timing/timing.h>

Initialize the timing subsystem.

Perform the necessary steps to initialize the timing subsystem.

◆ timing_start()

void timing_start ( void )

#include <zephyr/timing/timing.h>

Signal the start of the timing information gathering.

Signal to the timing subsystem that timing information will be gathered from this point forward.

◆ timing_stop()

void timing_stop ( void )

#include <zephyr/timing/timing.h>

Signal the end of the timing information gathering.

Signal to the timing subsystem that timing information is no longer being gathered from this point forward.