dead stuff

This commit is contained in:
Matthew Kennedy 2023-03-02 02:21:53 -08:00
parent 3aba369b30
commit aa48077d58
11 changed files with 0 additions and 1617 deletions

View File

@ -235,7 +235,6 @@ CSRC = check.c \
$(BOARDSRC) \
$(CHIBIOS_CONTRIB)/os/various/ramdisk.c \
$(CHIBIOS)/os/various/evtimer.c \
$(DEV_SRC) \
$(BOOTLOADERSRC) \
${HW_MASS_STORAGE_SRC_C} \
$(HW_LAYER_EMS) \

View File

@ -173,7 +173,6 @@ include $(PROJECT_DIR)/hw_layer/drivers/drivers.mk
# setting.
CSRC = $(ALLCSRC) \
$(BOARDSRC) \
$(DEV_SRC) \
$(HW_LAYER_EMS) \
$(HW_LAYER_DRIVERS_CORE) \
$(FATFSSRC) \

View File

@ -288,10 +288,8 @@
#define EFI_SENSOR_CHART TRUE
#if defined __GNUC__
#define EFI_PERF_METRICS FALSE
#define DL_OUTPUT_BUFFER 6500
#else
#define EFI_PERF_METRICS FALSE
#define DL_OUTPUT_BUFFER 8000
#endif

View File

@ -1,10 +1,6 @@
DEVELOPMENT_DIR=$(PROJECT_DIR)/development
DEV_SRC = $(DEVELOPMENT_DIR)/test/test.c \
$(DEVELOPMENT_DIR)/test/testbmk.c
DEV_SRC_CPP = $(DEVELOPMENT_DIR)/sensor_chart.cpp \
$(DEVELOPMENT_DIR)/rfi_perftest.cpp \
$(DEVELOPMENT_DIR)/engine_emulator.cpp \
$(DEVELOPMENT_DIR)/engine_sniffer.cpp \
$(DEVELOPMENT_DIR)/logic_analyzer.cpp \

View File

@ -1,305 +0,0 @@
/**
* @file rfi_perftest.cpp
*
* Method execution time micro test.
*
* @date Nov 30, 2012
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pch.h"
#include "rfi_perftest.h"
#include "fuel_math.h"
#include "eficonsole.h"
#include "time.h"
#include "console_io.h"
#if EFI_PERF_METRICS
#include "test.h"
static void testSystemCalls(const int count) {
time_t start, time;
long result = 0;
start = getTimeNowMs();
for (int i = 0; i < count / 2; i++) {
// setPinValue(&testOutput, 0);
// setPinValue(&testOutput, 1);
}
time = getTimeNowMs() - start;
// Finished 100000 iterations of 'setPinValue()' in 120ms
// prin("Finished %d iterations of 'setPinValue()' in %dms\r\n", count, time);
start = getTimeNowMs();
for (int i = 0; i < count; i++)
result += chTimeNow();
time = getTimeNowMs() - start;
if (result != 0) {
// Finished 100000 iterations of 'chTimeNow()' in 33ms
efiPrintf("Finished %d iterations of 'chTimeNow()' in %dms", count, time);
}
start = getTimeNowMs();
for (int i = 0; i < count; i++) {
chSysLock()
;
result += chTimeNow();
chSysUnlock()
;
}
time = getTimeNowMs() - start;
if (result != 0) {
// Finished 100000 iterations of 'chTimeNow()' with chSysLock in 144ms
efiPrintf("Finished %d iterations of 'chTimeNow()' with chSysLock in %dms", count, time);
}
start = getTimeNowMs();
for (int i = 0; i < count; i++)
result += getTimeNowMs();
time = getTimeNowMs() - start;
if (result != 0)
efiPrintf("Finished %d iterations of 'getTimeNowMs' in %dms", count, time);
}
static Engine testEngine;
static void testRusefiMethods(const int count) {
time_t start, time;
int tempi = 1;
start = getTimeNowMs();
time = getTimeNowMs() - start;
if (tempi != 0)
efiPrintf("Finished %d iterations of getBaseFuel in %dms", count, time);
// start = getTimeNowMs();
// for (int i = 0; i < count; i++)
// tempi += getInjectionDuration(1200, NULL); // todo
// time = getTimeNowMs() - start;
// if (tempi != 0)
// efiPrintf("Finished %d iterations of getFuelMs in %dms", count, time);
start = getTimeNowMs();
for (int i = 0; i < count; i++) {
testEngine.updateSlowSensors();
tempi += testEngine.engineState.clt;
}
time = getTimeNowMs() - start;
if (tempi != 0)
efiPrintf("Finished %d iterations of updateSlowSensors in %dms", count, time);
}
static void testMath(const int count) {
time_t start, time;
int64_t temp64 = 0;
start = getTimeNowMs();
for (int64_t i = 0; i < count; i++) {
temp64 += i;
}
time = getTimeNowMs() - start;
if (temp64 != 0) {
efiPrintf("Finished %d iterations of int64_t summation in %dms", count, time);
}
temp64 = 1;
start = getTimeNowMs();
for (int64_t i = 0; i < count; i++) {
temp64 *= i;
}
time = getTimeNowMs() - start;
if (temp64 == 0) {
efiPrintf("Finished %d iterations of int64_t multiplication in %dms", count, time);
}
start = getTimeNowMs();
for (int i = 0; i < count; i++)
;
time = getTimeNowMs() - start;
efiPrintf("Finished %d iterations of empty loop in %dms", count, time);
uint32_t tempi = 1;
start = getTimeNowMs();
for (int i = 0; i < count; i++) {
tempi += tempi;
}
time = getTimeNowMs() - start;
if (tempi == 0) {
// 11ms is 1848000 ticks
// 18.48 ticks per iteration
// Finished 100000 iterations of uint32_t summation in 11ms
efiPrintf("Finished %d iterations of uint32_t summation in %dms", count, time);
}
start = getTimeNowMs();
tempi = 1;
for (int i = 0; i < count; i++) {
tempi += (tempi + 100) / 130;
}
time = getTimeNowMs() - start;
if (tempi != 0) {
// Finished 100000 iterations of uint32_t division in 16ms
efiPrintf("Finished %d iterations of uint32_t division in %dms", count, time);
}
start = getTimeNowMs();
temp64 = 1;
for (int i = 0; i < count; i++) {
temp64 += temp64;
}
time = getTimeNowMs() - start;
if (temp64 == 0) {
// Finished 100000 iterations of int64_t summation in 21ms
efiPrintf("Finished %d iterations of int64_t summation in %dms", count, time);
}
start = getTimeNowMs();
temp64 = 1;
for (int i = 0; i < count; i++) {
temp64 += (temp64 + 100) / 130;
}
time = getTimeNowMs() - start;
if (temp64 != 0) {
// Finished 100000 iterations of int64_t division in 181ms
efiPrintf("Finished %d iterations of int64_t division in %dms", count, time);
}
start = getTimeNowMs();
float tempf = 1;
for (int i = 0; i < count; i++) {
tempf += tempf;
}
time = getTimeNowMs() - start;
if (tempf != 0) {
efiPrintf("Finished %d iterations of float summation in %dms", count, time);
}
start = getTimeNowMs();
tempf = 1;
for (int i = 0; i < count; i++) {
tempf += tempf * 130.0f;
}
time = getTimeNowMs() - start;
if (tempf != 0) {
// ms = ticks
// ticks per iteration
// Finished 100000 iterations of float division in ms
efiPrintf("Finished %d iterations of float multiplication in %dms", count, time);
}
start = getTimeNowMs();
tempf = 1;
for (int i = 0; i < count; i++) {
tempf += (tempf + 100) / 130.0;
}
time = getTimeNowMs() - start;
if (tempf != 0) {
// 65 ms = 10920000 ticks
// 109.2 ticks per iteration
// Finished 100000 iterations of float division in 65ms
efiPrintf("Finished %d iterations of float division in %dms", count, time);
}
start = getTimeNowMs();
tempf = 1;
for (int i = 0; i < count; i++) {
tempf += logf(tempf);
}
time = getTimeNowMs() - start;
if (tempf != 0) {
// Finished 100000 iterations of float log in 191ms
efiPrintf("Finished %d iterations of float log in %dms", count, time);
}
start = getTimeNowMs();
double tempd = 1;
for (int i = 0; i < count; i++)
tempd += tempd / 2;
time = getTimeNowMs() - start;
if (tempd != 0) {
// Finished 100000 iterations of double summation in 80ms
efiPrintf("Finished %d iterations of double summation in %dms", count, time);
}
start = getTimeNowMs();
tempd = 1;
for (int i = 0; i < count; i++)
tempd += (tempd + 100) / 130.0;
time = getTimeNowMs() - start;
if (tempd != 0) {
// Finished 100000 iterations of double division in 497ms
efiPrintf("Finished %d iterations of double division in %dms", count, time);
}
start = getTimeNowMs();
tempd = 1;
for (int i = 0; i < count; i++) {
tempd += log(tempd);
}
time = getTimeNowMs() - start;
if (tempd != 0) {
// Finished 100000 iterations of double log in 242ms
efiPrintf("Finished %d iterations of double log in %dms", count, time);
}
}
static void runTests(const int count) {
efiPrintf("Running tests: %d", count);
testRusefiMethods(count / 10);
testSystemCalls(count);
testMath(count);
}
extern Overflow64Counter halTime;
#if EFI_RTC
static int rtcStartTime;
#endif
#include "chrtclib.h"
static void timeInfo() {
efiPrintf("chTimeNow as seconds = %d", getTimeNowS());
efiPrintf("hal seconds = %d", halTime.get() / (long)CORE_CLOCK);
#if EFI_RTC
int unix = rtcGetTimeUnixSec(&RTCD1) - rtcStartTime;
efiPrintf("unix seconds = %d", unix);
#endif
}
static void runChibioTest() {
print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT);
print("EFI_EMULATE_POSITION_SENSORS=%d\r\n", EFI_EMULATE_POSITION_SENSORS);
print("EFI_ANALOG_SENSORS=%d\r\n", EFI_ANALOG_SENSORS);
print("EFI_INTERNAL_ADC=%d\r\n", EFI_INTERNAL_ADC);
print("EFI_MAP_AVERAGING=%d\r\n", EFI_MAP_AVERAGING);
print("EFI_LOGIC_ANALYZER=%d\r\n", EFI_LOGIC_ANALYZER);
print("EFI_ENGINE_SNIFFER=%d\r\n", EFI_ENGINE_SNIFFER);
print("EFI_SENSOR_CHART=%d\r\n", EFI_SENSOR_CHART);
print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT);
print("EFI_ENGINE_CONTROL=%d\r\n", EFI_ENGINE_CONTROL);
print("CH_DBG_SYSTEM_STATE_CHECK=%d\r\n", CH_DBG_SYSTEM_STATE_CHECK);
print("CH_DBG_ENABLE_CHECKS=%d\r\n", CH_DBG_ENABLE_CHECKS);
print("CH_DBG_ENABLE_ASSERTS=%d\r\n", CH_DBG_ENABLE_ASSERTS);
print("CH_DBG_ENABLE_STACK_CHECK=%d\r\n", CH_DBG_ENABLE_STACK_CHECK);
print("CH_DBG_THREADS_PROFILING=%d\r\n", CH_DBG_THREADS_PROFILING);
TestThread(getConsoleChannel());
}
void initTimePerfActions() {
#if EFI_RTC
rtcStartTime = rtcGetTimeUnixSec(&RTCD1);
#endif
addConsoleActionI("perftest", runTests);
addConsoleAction("timeinfo", timeInfo);
addConsoleAction("chtest", runChibioTest);
}
#endif /* EFI_PERF_METRICS */

View File

@ -1,12 +0,0 @@
/**
* @file rfi_perftest.h
*
* @date Nov 30, 2012
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#include "global.h"
void initTimePerfActions();

View File

@ -1,370 +0,0 @@
/*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file test.c
* @brief Tests support code.
*
* @addtogroup test
* @{
*/
#if EFI_PERF_METRICS
#include "test.h"
#include "testbmk.h"
/*
* Array of all the test patterns.
*/
static ROMCONST struct testcase * ROMCONST *patterns[] = {
patternbmk,
NULL
};
static bool local_fail, global_fail;
static unsigned failpoint;
static char tokens_buffer[MAX_TOKENS];
static char *tokp;
/*
* Static working areas, the following areas can be used for threads or
* used as temporary buffers.
*/
union test_buffers test;
/*
* Pointers to the spawned threads.
*/
thread_t *threads[MAX_THREADS];
/*
* Pointers to the working areas.
*/
void * ROMCONST wa[5] = {test.wa.T0, test.wa.T1, test.wa.T2,
test.wa.T3, test.wa.T4};
/*
* Console output.
*/
static BaseSequentialStream *chp;
/**
* @brief Prints a decimal unsigned number.
*
* @param[in] n the number to be printed
*/
void test_printn(uint32_t n) {
char buf[16], *p;
if (!n)
chSequentialStreamPut(chp, '0');
else {
p = buf;
while (n)
*p++ = (n % 10) + '0', n /= 10;
while (p > buf)
chSequentialStreamPut(chp, *--p);
}
}
/**
* @brief Prints a line without final end-of-line.
*
* @param[in] msgp the message
*/
void test_print(const char *msgp) {
while (*msgp)
chSequentialStreamPut(chp, *msgp++);
}
/**
* @brief Prints a line.
*
* @param[in] msgp the message
*/
void test_println(const char *msgp) {
test_print(msgp);
chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2);
}
/*
* Tokens.
*/
static void clear_tokens(void) {
tokp = tokens_buffer;
}
static void print_tokens(void) {
char *cp = tokens_buffer;
while (cp < tokp)
chSequentialStreamPut(chp, *cp++);
}
/**
* @brief Emits a token into the tokens buffer.
*
* @param[in] token the token as a char
*/
void test_emit_token(char token) {
chSysLock();
*tokp++ = token;
chSysUnlock();
}
/*
* Assertions.
*/
bool _test_fail(unsigned point) {
local_fail = TRUE;
global_fail = TRUE;
failpoint = point;
return TRUE;
}
bool _test_assert(unsigned point, bool condition) {
if (!condition)
return _test_fail(point);
return FALSE;
}
bool _test_assert_sequence(unsigned point, char *expected) {
char *cp = tokens_buffer;
while (cp < tokp) {
if (*cp++ != *expected++)
return _test_fail(point);
}
if (*expected)
return _test_fail(point);
clear_tokens();
return FALSE;
}
bool _test_assert_time_window(unsigned point, systime_t start, systime_t end) {
return _test_assert(point, chTimeIsWithin(start, end));
}
/*
* Threads utils.
*/
/**
* @brief Sets a termination request in all the test-spawned threads.
*/
void test_terminate_threads(void) {
int i;
for (i = 0; i < MAX_THREADS; i++)
if (threads[i])
chThdTerminate(threads[i]);
}
/**
* @brief Waits for the completion of all the test-spawned threads.
*/
void test_wait_threads(void) {
int i;
for (i = 0; i < MAX_THREADS; i++)
if (threads[i] != NULL) {
chThdWait(threads[i]);
threads[i] = NULL;
}
}
#if CH_DBG_THREADS_PROFILING
/**
* @brief CPU pulse.
* @note The current implementation is not totally reliable.
*
* @param[in] duration CPU pulse duration in milliseconds
*/
void test_cpu_pulse(unsigned duration) {
systime_t start, end, now;
start = chThdSelf()->p_time;
end = start + TIME_MS2I(duration);
do {
now = chThdSelf()->p_time;
#if defined(SIMULATOR)
ChkIntSources();
#endif
}
while (end > start ? (now >= start) && (now < end) :
(now >= start) || (now < end));
}
#endif
/**
* @brief Delays execution until next system time tick.
*
* @return The system time.
*/
systime_t test_wait_tick(void) {
chThdSleep(1);
return chTimeNow();
}
/*
* Timer utils.
*/
/**
* @brief Set to @p TRUE when the test timer reaches its deadline.
*/
bool test_timer_done;
static VirtualTimer vt;
static void tmr(void *p) {
(void)p;
test_timer_done = TRUE;
}
/**
* @brief Starts the test timer.
*
* @param[in] ms time in milliseconds
*/
void test_start_timer(unsigned ms) {
systime_t duration = TIME_MS2I(ms);
test_timer_done = FALSE;
chVTSet(&vt, duration, tmr, NULL);
}
/*
* Test suite execution.
*/
static void execute_test(const struct testcase *tcp) {
int i;
/* Initialization */
clear_tokens();
local_fail = FALSE;
for (i = 0; i < MAX_THREADS; i++)
threads[i] = NULL;
if (tcp->setup != NULL)
tcp->setup();
tcp->execute();
if (tcp->teardown != NULL)
tcp->teardown();
test_wait_threads();
}
static void print_line(void) {
unsigned i;
for (i = 0; i < 76; i++)
chSequentialStreamPut(chp, '-');
chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2);
}
/**
* @brief Test execution thread function.
*
* @param[in] p pointer to a @p BaseChannel object for test output
* @return A failure boolean value.
*/
msg_t TestThread(void *p) {
int i, j;
chp = p;
test_println("");
test_println("*** ChibiOS/RT test suite");
test_println("***");
test_print("*** Kernel: ");
test_println(CH_KERNEL_VERSION);
test_print("*** Compiled: ");
test_println(__DATE__ " - " __TIME__);
#ifdef CH_COMPILER_NAME
test_print("*** Compiler: ");
test_println(CH_COMPILER_NAME);
#endif
test_print("*** Architecture: ");
test_println(CH_ARCHITECTURE_NAME);
#ifdef CH_CORE_VARIANT_NAME
test_print("*** Core Variant: ");
test_println(CH_CORE_VARIANT_NAME);
#endif
#ifdef CH_PORT_INFO
test_print("*** Port Info: ");
test_println(CH_PORT_INFO);
#endif
#ifdef PLATFORM_NAME
test_print("*** Platform: ");
test_println(PLATFORM_NAME);
#endif
#ifdef BOARD_NAME
test_print("*** Test Board: ");
test_println(BOARD_NAME);
#endif
test_println("");
global_fail = FALSE;
i = 0;
while (patterns[i]) {
j = 0;
while (patterns[i][j]) {
print_line();
test_print("--- Test Case ");
test_printn(i + 1);
test_print(".");
test_printn(j + 1);
test_print(" (");
test_print(patterns[i][j]->name);
test_println(")");
#if DELAY_BETWEEN_TESTS > 0
chThdSleepMilliseconds(DELAY_BETWEEN_TESTS);
#endif
execute_test(patterns[i][j]);
if (local_fail) {
test_print("--- Result: FAILURE (#");
test_printn(failpoint);
test_print(" [");
print_tokens();
test_println("])");
}
else
test_println("--- Result: SUCCESS");
j++;
}
i++;
}
print_line();
test_println("");
test_print("Final result: ");
if (global_fail)
test_println("FAILURE");
else
test_println("SUCCESS");
return (msg_t)global_fail;
}
/** @} */
#endif /* EFI_PERF_METRICS */

View File

@ -1,173 +0,0 @@
/*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file test.h
* @brief Tests support header.
*
* @addtogroup test
* @{
*/
#ifndef _TEST_H_
#define _TEST_H_
/**
* @brief Delay inserted between test cases.
*/
#if !defined(DELAY_BETWEEN_TESTS)
#define DELAY_BETWEEN_TESTS 200
#endif
/**
* @brief If @p TRUE then benchmarks are not included.
*/
#if !defined(TEST_NO_BENCHMARKS)
#define TEST_NO_BENCHMARKS FALSE
#endif
#define MAX_THREADS 5
#define MAX_TOKENS 16
#if defined(CH_ARCHITECTURE_AVR) || defined(CH_ARCHITECTURE_MSP430)
#define THREADS_STACK_SIZE 48
#elif defined(CH_ARCHITECTURE_STM8)
#define THREADS_STACK_SIZE 64
#elif defined(CH_ARCHITECTURE_SIMIA32)
#define THREADS_STACK_SIZE 512
#else
#define THREADS_STACK_SIZE 128
#endif
#define WA_SIZE THD_WA_SIZE(THREADS_STACK_SIZE)
/**
* @brief Structure representing a test case.
*/
struct testcase {
const char *name; /**< @brief Test case name. */
void (*setup)(void); /**< @brief Test case preparation function. */
void (*teardown)(void); /**< @brief Test case clean up function. */
void (*execute)(void); /**< @brief Test case execution function. */
};
#ifndef __DOXYGEN__
union test_buffers {
struct {
WORKING_AREA(T0, THREADS_STACK_SIZE);
WORKING_AREA(T1, THREADS_STACK_SIZE);
WORKING_AREA(T2, THREADS_STACK_SIZE);
WORKING_AREA(T3, THREADS_STACK_SIZE);
WORKING_AREA(T4, THREADS_STACK_SIZE);
} wa;
uint8_t buffer[WA_SIZE * 5];
};
#endif
#ifdef __cplusplus
extern "C" {
#endif
msg_t TestThread(void *p);
void test_printn(uint32_t n);
void test_print(const char *msgp);
void test_println(const char *msgp);
void test_emit_token(char token);
bool _test_fail(unsigned point);
bool _test_assert(unsigned point, bool condition);
bool _test_assert_sequence(unsigned point, char *expected);
bool _test_assert_time_window(unsigned point, systime_t start, systime_t end);
void test_terminate_threads(void);
void test_wait_threads(void);
systime_t test_wait_tick(void);
void test_start_timer(unsigned ms);
#if CH_DBG_THREADS_PROFILING
void test_cpu_pulse(unsigned duration);
#endif
#if defined(WIN32)
void ChkIntSources(void);
#endif
#ifdef __cplusplus
}
#endif
/**
* @brief Test failure enforcement.
*/
#define test_fail(point) { \
_test_fail(point); \
return; \
}
/**
* @brief Test assertion.
*
* @param[in] point numeric assertion identifier
* @param[in] condition a boolean expression that must be verified to be true
* @param[in] msg failure message
*/
#define test_assert(point, condition, msg) { \
if (_test_assert(point, condition)) \
return; \
}
/**
* @brief Test assertion with lock.
*
* @param[in] point numeric assertion identifier
* @param[in] condition a boolean expression that must be verified to be true
* @param[in] msg failure message
*/
#define test_assert_lock(point, condition, msg) { \
chSysLock(); \
if (_test_assert(point, condition)) { \
chSysUnlock(); \
return; \
} \
chSysUnlock(); \
}
/**
* @brief Test sequence assertion.
*
* @param[in] point numeric assertion identifier
* @param[in] expected string to be matched with the tokens buffer
*/
#define test_assert_sequence(point, expected) { \
if (_test_assert_sequence(point, expected)) \
return; \
}
/**
* @brief Test time window assertion.
*
* @param[in] point numeric assertion identifier
* @param[in] start initial time in the window (included)
* @param[in] end final time in the window (not included)
*/
#define test_assert_time_window(point, start, end) { \
if (_test_assert_time_window(point, start, end)) \
return; \
}
#if !defined(__DOXYGEN__)
extern Thread *threads[MAX_THREADS];
extern union test_buffers test;
extern void * ROMCONST wa[];
extern bool test_timer_done;
#endif
#endif /* _TEST_H_ */
/** @} */

View File

@ -1,722 +0,0 @@
/*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#if EFI_PERF_METRICS
#include "test.h"
/**
* @page test_benchmarks Kernel Benchmarks
*
* File: @ref testbmk.c
*
* <h2>Description</h2>
* This module implements a series of system benchmarks. The benchmarks are
* useful as a stress test and as a reference when comparing ChibiOS/RT
* with similar systems.
*
* <h2>Objective</h2>
* Objective of the test module is to provide a performance index for the
* most critical system subsystems. The performance numbers allow to
* discover performance regressions between successive ChibiOS/RT releases.
*
* <h2>Preconditions</h2>
* None.
*
* <h2>Test Cases</h2>
* - @subpage test_benchmarks_001
* - @subpage test_benchmarks_002
* - @subpage test_benchmarks_003
* - @subpage test_benchmarks_004
* - @subpage test_benchmarks_005
* - @subpage test_benchmarks_006
* - @subpage test_benchmarks_007
* - @subpage test_benchmarks_008
* - @subpage test_benchmarks_009
* - @subpage test_benchmarks_010
* - @subpage test_benchmarks_011
* - @subpage test_benchmarks_012
* - @subpage test_benchmarks_013
* .
* @file testbmk.c Kernel Benchmarks
* @brief Kernel Benchmarks source file
* @file testbmk.h
* @brief Kernel Benchmarks header file
*/
static Semaphore sem1;
#if CH_USE_MUTEXES
static Mutex mtx1;
#endif
static msg_t thread1(void *p) {
Thread *tp;
msg_t msg;
(void)p;
do {
tp = chMsgWait();
msg = chMsgGet(tp);
chMsgRelease(tp, msg);
} while (msg);
return 0;
}
#ifdef __GNUC__
__attribute__((noinline))
#endif
static unsigned int msg_loop_test(Thread *tp) {
uint32_t n = 0;
test_wait_tick();
test_start_timer(1000);
do {
(void)chMsgSend(tp, 1);
n++;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
(void)chMsgSend(tp, 0);
return n;
}
/**
* @page test_benchmarks_001 Messages performance #1
*
* <h2>Description</h2>
* A message server thread is created with a lower priority than the client
* thread, the messages throughput per second is measured and the result
* printed in the output log.
*/
static void bmk1_execute(void) {
uint32_t n;
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread1, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
test_printn(n);
test_print(" msgs/S, ");
test_printn(n << 1);
test_println(" ctxswc/S");
}
ROMCONST struct testcase testbmk1 = {
"Benchmark, messages #1",
NULL,
NULL,
bmk1_execute
};
/**
* @page test_benchmarks_002 Messages performance #2
*
* <h2>Description</h2>
* A message server thread is created with an higher priority than the client
* thread, the messages throughput per second is measured and the result
* printed in the output log.
*/
static void bmk2_execute(void) {
uint32_t n;
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
test_printn(n);
test_print(" msgs/S, ");
test_printn(n << 1);
test_println(" ctxswc/S");
}
ROMCONST struct testcase testbmk2 = {
"Benchmark, messages #2",
NULL,
NULL,
bmk2_execute
};
static msg_t thread2(void *p) {
return (msg_t)p;
}
/**
* @page test_benchmarks_003 Messages performance #3
*
* <h2>Description</h2>
* A message server thread is created with an higher priority than the client
* thread, four lower priority threads crowd the ready list, the messages
* throughput per second is measured while the ready list and the result
* printed in the output log.
*/
static void bmk3_execute(void) {
uint32_t n;
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2, NULL);
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2, NULL);
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-4, thread2, NULL);
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-5, thread2, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
test_printn(n);
test_print(" msgs/S, ");
test_printn(n << 1);
test_println(" ctxswc/S");
}
ROMCONST struct testcase testbmk3 = {
"Benchmark, messages #3",
NULL,
NULL,
bmk3_execute
};
/**
* @page test_benchmarks_004 Context Switch performance
*
* <h2>Description</h2>
* A thread is created that just performs a @p chSchGoSleepS() into a loop,
* the thread is awakened as fast is possible by the tester thread.<br>
* The Context Switch performance is calculated by measuring the number of
* iterations after a second of continuous operations.
*/
msg_t thread4(void *p) {
msg_t msg;
Thread *self = chThdSelf();
(void)p;
chSysLock();
do {
chSchGoSleepS(THD_STATE_SUSPENDED);
msg = self->p_u.rdymsg;
} while (msg == RDY_OK);
chSysUnlock();
return 0;
}
static void bmk4_execute(void) {
Thread *tp;
uint32_t n;
tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread4, NULL);
n = 0;
test_wait_tick();
test_start_timer(1000);
do {
chSysLock();
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, RDY_OK);
chSchWakeupS(tp, RDY_OK);
chSysUnlock();
n += 4;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
chSysLock();
chSchWakeupS(tp, RDY_TIMEOUT);
chSysUnlock();
test_wait_threads();
test_print("--- Score : ");
test_printn(n * 2);
test_println(" ctxswc/S");
}
ROMCONST struct testcase testbmk4 = {
"Benchmark, context switch",
NULL,
NULL,
bmk4_execute
};
/**
* @page test_benchmarks_005 Threads performance, full cycle
*
* <h2>Description</h2>
* Threads are continuously created and terminated into a loop. A full
* @p chThdCreateStatic() / @p chThdExit() / @p chThdWait() cycle is performed
* in each iteration.<br>
* The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
static void bmk5_execute(void) {
uint32_t n = 0;
void *wap = wa[0];
tprio_t prio = chThdGetPriority() - 1;
test_wait_tick();
test_start_timer(1000);
do {
chThdWait(chThdCreateStatic(wap, WA_SIZE, prio, thread2, NULL));
n++;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
test_print("--- Score : ");
test_printn(n);
test_println(" threads/S");
}
ROMCONST struct testcase testbmk5 = {
"Benchmark, threads, full cycle",
NULL,
NULL,
bmk5_execute
};
/**
* @page test_benchmarks_006 Threads performance, create/exit only
*
* <h2>Description</h2>
* Threads are continuously created and terminated into a loop. A partial
* @p chThdCreateStatic() / @p chThdExit() cycle is performed in each
* iteration, the @p chThdWait() is not necessary because the thread is
* created at an higher priority so there is no need to wait for it to
* terminate.<br>
* The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
static void bmk6_execute(void) {
uint32_t n = 0;
void *wap = wa[0];
tprio_t prio = chThdGetPriority() + 1;
test_wait_tick();
test_start_timer(1000);
do {
chThdCreateStatic(wap, WA_SIZE, prio, thread2, NULL);
n++;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
test_print("--- Score : ");
test_printn(n);
test_println(" threads/S");
}
ROMCONST struct testcase testbmk6 = {
"Benchmark, threads, create only",
NULL,
NULL,
bmk6_execute
};
/**
* @page test_benchmarks_007 Mass reschedule performance
*
* <h2>Description</h2>
* Five threads are created and atomically rescheduled by resetting the
* semaphore where they are waiting on. The operation is performed into a
* continuous loop.<br>
* The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
static msg_t thread3(void *p) {
(void)p;
while (!chThdShouldTerminate())
chSemWait(&sem1);
return 0;
}
static void bmk7_setup(void) {
chSemInit(&sem1, 0);
}
static void bmk7_execute(void) {
uint32_t n;
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread3, NULL);
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+4, thread3, NULL);
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread3, NULL);
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+2, thread3, NULL);
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+1, thread3, NULL);
n = 0;
test_wait_tick();
test_start_timer(1000);
do {
chSemReset(&sem1, 0);
n++;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
test_terminate_threads();
chSemReset(&sem1, 0);
test_wait_threads();
test_print("--- Score : ");
test_printn(n);
test_print(" reschedules/S, ");
test_printn(n * 6);
test_println(" ctxswc/S");
}
ROMCONST struct testcase testbmk7 = {
"Benchmark, mass reschedule, 5 threads",
bmk7_setup,
NULL,
bmk7_execute
};
/**
* @page test_benchmarks_008 I/O Round-Robin voluntary reschedule.
*
* <h2>Description</h2>
* Five threads are created at equal priority, each thread just increases a
* variable and yields.<br>
* The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
static msg_t thread8(void *p) {
do {
chThdYield();
chThdYield();
chThdYield();
chThdYield();
(*(uint32_t *)p) += 4;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while(!chThdShouldTerminate());
return 0;
}
static void bmk8_execute(void) {
uint32_t n;
n = 0;
test_wait_tick();
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
chThdSleepSeconds(1);
test_terminate_threads();
test_wait_threads();
test_print("--- Score : ");
test_printn(n);
test_println(" ctxswc/S");
}
ROMCONST struct testcase testbmk8 = {
"Benchmark, round robin context switching",
NULL,
NULL,
bmk8_execute
};
#if CH_USE_QUEUES
/**
* @page test_benchmarks_009 I/O Queues throughput
*
* <h2>Description</h2>
* Four bytes are written and then read from an @p InputQueue into a continuous
* loop.<br>
* The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
static void bmk9_execute(void) {
uint32_t n;
static uint8_t ib[16];
static InputQueue iq;
chIQInit(&iq, ib, sizeof(ib), NULL, NULL);
n = 0;
test_wait_tick();
test_start_timer(1000);
do {
chSysLock();
chIQPutI(&iq, 0);
chIQPutI(&iq, 1);
chIQPutI(&iq, 2);
chIQPutI(&iq, 3);
chSysUnlock();
(void)chIQGet(&iq);
(void)chIQGet(&iq);
(void)chIQGet(&iq);
(void)chIQGet(&iq);
n++;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
test_print("--- Score : ");
test_printn(n * 4);
test_println(" bytes/S");
}
ROMCONST struct testcase testbmk9 = {
"Benchmark, I/O Queues throughput",
NULL,
NULL,
bmk9_execute
};
#endif /* CH_USE_QUEUES */
/**
* @page test_benchmarks_010 Virtual Timers set/reset performance
*
* <h2>Description</h2>
* A virtual timer is set and immediately reset into a continuous loop.<br>
* The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
static void tmo(void *param) {(void)param;}
static void bmk10_execute(void) {
static VirtualTimer vt1, vt2;
uint32_t n = 0;
test_wait_tick();
test_start_timer(1000);
do {
chSysLock();
chVTSetI(&vt1, 1, tmo, NULL);
chVTSetI(&vt2, 10000, tmo, NULL);
chVTResetI(&vt1);
chVTResetI(&vt2);
chSysUnlock();
n++;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
test_print("--- Score : ");
test_printn(n * 2);
test_println(" timers/S");
}
ROMCONST struct testcase testbmk10 = {
"Benchmark, virtual timers set/reset",
NULL,
NULL,
bmk10_execute
};
#if CH_USE_SEMAPHORES
/**
* @page test_benchmarks_011 Semaphores wait/signal performance
*
* <h2>Description</h2>
* A counting semaphore is taken/released into a continuous loop, no Context
* Switch happens because the counter is always non negative.<br>
* The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
static void bmk11_setup(void) {
chSemInit(&sem1, 1);
}
static void bmk11_execute(void) {
uint32_t n = 0;
test_wait_tick();
test_start_timer(1000);
do {
chSemWait(&sem1);
chSemSignal(&sem1);
chSemWait(&sem1);
chSemSignal(&sem1);
chSemWait(&sem1);
chSemSignal(&sem1);
chSemWait(&sem1);
chSemSignal(&sem1);
n++;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
test_print("--- Score : ");
test_printn(n * 4);
test_println(" wait+signal/S");
}
ROMCONST struct testcase testbmk11 = {
"Benchmark, semaphores wait/signal",
bmk11_setup,
NULL,
bmk11_execute
};
#endif /* CH_USE_SEMAPHORES */
#if CH_USE_MUTEXES
/**
* @page test_benchmarks_012 Mutexes lock/unlock performance
*
* <h2>Description</h2>
* A mutex is locked/unlocked into a continuous loop, no Context Switch happens
* because there are no other threads asking for the mutex.<br>
* The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
static void bmk12_setup(void) {
chMtxInit(&mtx1);
}
static void bmk12_execute(void) {
uint32_t n = 0;
test_wait_tick();
test_start_timer(1000);
do {
chMtxLock(&mtx1);
chMtxUnlock();
chMtxLock(&mtx1);
chMtxUnlock();
chMtxLock(&mtx1);
chMtxUnlock();
chMtxLock(&mtx1);
chMtxUnlock();
n++;
#if defined(SIMULATOR)
ChkIntSources();
#endif
} while (!test_timer_done);
test_print("--- Score : ");
test_printn(n * 4);
test_println(" lock+unlock/S");
}
ROMCONST struct testcase testbmk12 = {
"Benchmark, mutexes lock/unlock",
bmk12_setup,
NULL,
bmk12_execute
};
#endif
/**
* @page test_benchmarks_013 RAM Footprint
*
* <h2>Description</h2>
* The memory size of the various kernel objects is printed.
*/
static void bmk13_execute(void) {
test_print("--- System: ");
test_printn(sizeof(ReadyList) + sizeof(VTList) +
PORT_IDLE_THREAD_STACK_SIZE +
(sizeof(Thread) + sizeof(struct intctx) +
sizeof(struct extctx) +
PORT_INT_REQUIRED_STACK) * 2);
test_println(" bytes");
test_print("--- Thread: ");
test_printn(sizeof(Thread));
test_println(" bytes");
test_print("--- Timer : ");
test_printn(sizeof(VirtualTimer));
test_println(" bytes");
#if CH_USE_SEMAPHORES
test_print("--- Semaph: ");
test_printn(sizeof(Semaphore));
test_println(" bytes");
#endif
#if CH_USE_EVENTS
test_print("--- EventS: ");
test_printn(sizeof(EventSource));
test_println(" bytes");
test_print("--- EventL: ");
test_printn(sizeof(EventListener));
test_println(" bytes");
#endif
#if CH_USE_MUTEXES
test_print("--- Mutex : ");
test_printn(sizeof(Mutex));
test_println(" bytes");
#endif
#if CH_USE_CONDVARS
test_print("--- CondV.: ");
test_printn(sizeof(CondVar));
test_println(" bytes");
#endif
#if CH_USE_QUEUES
test_print("--- Queue : ");
test_printn(sizeof(GenericQueue));
test_println(" bytes");
#endif
#if CH_USE_MAILBOXES
test_print("--- MailB.: ");
test_printn(sizeof(Mailbox));
test_println(" bytes");
#endif
}
ROMCONST struct testcase testbmk13 = {
"Benchmark, RAM footprint",
NULL,
NULL,
bmk13_execute
};
/**
* @brief Test sequence for benchmarks.
*/
ROMCONST struct testcase * ROMCONST patternbmk[] = {
#if !TEST_NO_BENCHMARKS
&testbmk1,
&testbmk2,
&testbmk3,
&testbmk4,
&testbmk5,
&testbmk6,
&testbmk7,
&testbmk8,
#if CH_USE_QUEUES
&testbmk9,
#endif
&testbmk10,
#if CH_USE_SEMAPHORES
&testbmk11,
#endif
#if CH_USE_MUTEXES
&testbmk12,
#endif
&testbmk13,
#endif
NULL
};
#endif /* EFI_PERF_METRICS */

View File

@ -1,22 +0,0 @@
/*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _TESTBMK_H_
#define _TESTBMK_H_
extern ROMCONST struct testcase * ROMCONST patternbmk[];
#endif /* _TESTBMK_H_ */

View File

@ -121,7 +121,6 @@
#include "trigger_structure.h"
#include "hardware.h"
#include "rfi_perftest.h"
#include "rusefi.h"
#include "memstreams.h"
@ -288,10 +287,6 @@ void runRusEfiWithConfig() {
// This has to happen after RegisteredOutputPins are init'd: otherwise no change will be detected, and no init will happen
rememberCurrentConfiguration();
#if EFI_PERF_METRICS
initTimePerfActions();
#endif
runSchedulingPrecisionTestIfNeeded();
}
}