rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
perf_watch.c File Reference

The frame window, the table of lows and the line schedule behind the panel's console lines (perf_watch.h). More...

#include "perf_watch.h"
#include <string.h>

Functions

void perf_window_start (perf_window_t *w, int screen)
 Start an empty window on screen.
static void span_add (perf_span_t *s, uint32_t n, uint32_t us)
 Add us to s, the window's frame number n (0 first).
void perf_window_add (perf_window_t *w, int screen, uint32_t draw_us, uint32_t wait_us, uint32_t turn_us)
 Add one frame.
uint32_t perf_span_mean_us (const perf_span_t *s, uint32_t frames)
 The mean of one figure over frames, rounded to the nearest us.
void perf_lows_init (perf_lows_t *t)
 Empty the table.
void perf_name_copy (char dst[PERF_LOWS_NAME], const char *name)
 Copy a task's name into a row-sized buffer.
bool perf_lows_note (perf_lows_t *t, const char *name, uint32_t least)
 Note least free bytes for name.
int perf_lows_take (perf_lows_t *t)
 Take the first row due for a line.
perf_line_t perf_line_due (uint32_t frames)
 The line due after frame frames.

Detailed Description

The frame window, the table of lows and the line schedule behind the panel's console lines (perf_watch.h).

SPDX-License-Identifier: MIT

Function Documentation

◆ perf_line_due()

perf_line_t perf_line_due ( uint32_t frames)

The line due after frame frames.

The rate line closes a window of PERF_WINDOW_FRAMES frames; the window line follows on the next frame; every other frame may carry one row of the lows.

Parameters
framesFrames drawn since the loop started, this one included. 2^32 is not a multiple of 300: the window across the wrap is 196 frames long, 3.2s at 60.4fps after 2.25 years.
Returns
The line.

◆ perf_lows_init()

void perf_lows_init ( perf_lows_t * t)

Empty the table.

Parameters
tThe table.

◆ perf_lows_note()

bool perf_lows_note ( perf_lows_t * t,
const char * name,
uint32_t least )

Note least free bytes for name.

Parameters
tThe table.
nameThe task's name, or another the caller chooses; cut to PERF_LOWS_NAME - 1 bytes, of which no more are read (perf_name_copy()). NULL is noted as "".
leastThe least free bytes now.
Returns
true when the name is new or least is below its last figure, which it then becomes, and the row is due for a line; false when it held or rose, and for a new name when every row is in use, which counts in dropped.

◆ perf_lows_take()

int perf_lows_take ( perf_lows_t * t)

Take the first row due for a line.

Parameters
tThe table.
Returns
The row's index, no longer due; -1 when none is due.

◆ perf_name_copy()

void perf_name_copy ( char dst[PERF_LOWS_NAME],
const char * name )

Copy a task's name into a row-sized buffer.

Reads at most PERF_LOWS_NAME - 1 bytes of name and none past its terminator, so a name without one is cut, not run past.

Parameters
dstThe buffer, PERF_LOWS_NAME bytes; always terminated.
nameThe name; NULL is copied as "".

◆ perf_span_mean_us()

uint32_t perf_span_mean_us ( const perf_span_t * s,
uint32_t frames )

The mean of one figure over frames, rounded to the nearest us.

Parameters
sThe figure's span.
framesThe frames it was added over.
Returns
The mean, us; 0 with no frame.

◆ perf_window_add()

void perf_window_add ( perf_window_t * w,
int screen,
uint32_t draw_us,
uint32_t wait_us,
uint32_t turn_us )

Add one frame.

Parameters
wThe window.
screenThe screen the frame was drawn on; another than the window's starts the window again on it, with this frame.
draw_usThe frame's paint time, us.
wait_usHow long the flip after it blocked, us.
turn_usThe part of wait_us Screen rotation 180° spent copying the frame turned, us; 0 in NORMAL.

◆ perf_window_start()

void perf_window_start ( perf_window_t * w,
int screen )

Start an empty window on screen.

Parameters
wThe window.
screenThe screen its frames are drawn on.

◆ span_add()

void span_add ( perf_span_t * s,
uint32_t n,
uint32_t us )
static

Add us to s, the window's frame number n (0 first).

Parameters
sThe span.
nFrames added to the window before this one.
usThe figure, us.