17#if defined(HAS_OS_ACCESS)
18#error "Unexpected OS ACCESS HERE"
21#if EFI_HISTOGRAMS || EFI_UNIT_TEST
23#define H_ACCURACY 0.05
24#define H_CONFIDENCE 0.8
25#define LONG_MAX_INT 0x7fffffffffffffffL
28static float confidence_bounds[] = { 0.5 - H_CONFIDENCE * 0.5, 0.5, 0.5 + H_CONFIDENCE * 0.5 };
46 for (
int i = 1; i < BOUND_LENGTH; i++) {
47 int64_t prev = bounds[i - 1];
48 int64_t next = prev + (int64_t) ((
double) prev * H_ACCURACY);
55 bounds[BOUND_LENGTH - 1] = LONG_MAX_INT;
57 for (
int i = 0, j = 0; j < SBI_SIZE; i++)
58 while (j < bounds[i + 1] && j < SBI_SIZE)
73 int r = BOUND_LENGTH - 1;
76 if (bounds[m] > value)
78 else if (bounds[m + 1] <= value)
90 if (std::strlen(name) >
sizeof(h->
name) - 1) {
93 strcpy(h->
name, name);
120 for (
int j = 0; j < BOUND_LENGTH; j++) {
121 for (
int k = 0; k < h->
values[j]; k++) {
122 report[index++] = (bounds[j] + bounds[j + 1]) / 2;
129 while (h->
values[minIndex] == 0) {
132 report[index++] = h->
values[minIndex];
136 for (
int j = 0; j < 3; j++) {
146 while (acc + h->
values[minIndex] < k)
147 acc += h->
values[minIndex++];
148 if (k < h->total_count / 2)
149 while (acc + h->
values[minIndex] <= k)
150 acc += h->
values[minIndex++];
153 float d = bounds[minIndex];
155 d += (bounds[minIndex + 1] - 1 - bounds[minIndex]) * (k - acc) / h->
values[minIndex];
156 report[index++] = (int) d;
159 int maxIndex = BOUND_LENGTH - 1;
160 while (h->
values[maxIndex] == 0)
162 int64_t maxValue = bounds[maxIndex + 1] - 1;
163 report[index++] = maxValue;
void firmwareError(ObdCode code, const char *fmt,...)
static float confidence_bounds[]
int histogramGetIndex(int64_t value)
This internal method is only public so that we can test it.
void initHistogram(histogram_s *h, const char *name)
Reset histogram_s to orignal state.
void hsAdd(histogram_s *h, int64_t value)
static int64_t bounds[BOUND_LENGTH] CCM_OPTIONAL
int hsReport(histogram_s *h, int *report)
Prepare histogram report.
static int small_bounds_index[SBI_SIZE]
void initHistogramsModule(void)
This data structure is used to analyze CPU performance.