You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "lock.h"
|
|
|
|
/* Should be Power of 2! */
|
|
#define PERF_WINDOW_BUFFER_SIZE 256
|
|
|
|
#if ((PERF_WINDOW_BUFFER_SIZE == 0) || (PERF_WINDOW_BUFFER_SIZE & (PERF_WINDOW_BUFFER_SIZE - 1)) != 0)
|
|
#error "PERF_WINDOW_BUFFER_SIZE must be power of 2!"
|
|
#endif
|
|
|
|
/*
|
|
* The by_duration array sorts the last N executions by execution time
|
|
* The by_termination array acts as a circular buffer that maps to indices in the by_duration array
|
|
*
|
|
* by_termination ensures that the when the circular buffer is full, the oldest data in both arrays is
|
|
* overwritten, providing a sorted circular buffer
|
|
*/
|
|
struct execution_node {
|
|
uint64_t execution_time;
|
|
uint16_t by_termination_idx; /* Reverse idx of the associated by_termination bin. Used for swaps! */
|
|
};
|
|
|
|
struct perf_window {
|
|
char name[32];
|
|
struct execution_node by_duration[PERF_WINDOW_BUFFER_SIZE];
|
|
#ifdef GET_AVER_TIME
|
|
uint64_t by_duration_for_mdl[PERF_WINDOW_BUFFER_SIZE];
|
|
#endif
|
|
uint16_t by_termination[PERF_WINDOW_BUFFER_SIZE];
|
|
uint64_t count;
|
|
lock_t lock;
|
|
};
|