mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 12:55:12 +03:00
Projectkk2glider/performance tests (#4658)
* Transparency and fonts gtests added (Horus) * Added to CLI: Graphics performance test, memory speed test (Horus) * Gtests fixes
This commit is contained in:
parent
fc376b3603
commit
dc89d2d630
5 changed files with 366 additions and 4 deletions
|
@ -346,6 +346,296 @@ int cliTestNew()
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(COLORLCD)
|
||||
|
||||
extern bool perMainEnabled;
|
||||
typedef void (*graphichTestFunc)(void);
|
||||
|
||||
void testDrawSolidFilledRectangle()
|
||||
{
|
||||
lcdDrawFilledRect(0, 0, LCD_W, LCD_H, SOLID, TEXT_BGCOLOR);
|
||||
}
|
||||
|
||||
void testDrawFilledRectangle()
|
||||
{
|
||||
lcdDrawFilledRect(0, 0, LCD_W, LCD_H, DOTTED, TEXT_BGCOLOR);
|
||||
}
|
||||
|
||||
void testDrawSolidFilledRoundedRectangle()
|
||||
{
|
||||
lcdDrawFilledRect(0, 0, LCD_W/2, LCD_H/2, SOLID, ROUND|TEXT_BGCOLOR);
|
||||
}
|
||||
|
||||
void testDrawBlackOverlay()
|
||||
{
|
||||
lcdDrawBlackOverlay();
|
||||
}
|
||||
|
||||
void testDrawSolidHorizontalLine1()
|
||||
{
|
||||
lcdDrawSolidHorizontalLine(0, 0, 1, 0);
|
||||
}
|
||||
|
||||
void testDrawSolidHorizontalLine2()
|
||||
{
|
||||
lcdDrawSolidHorizontalLine(0, 0, LCD_W, 0);
|
||||
}
|
||||
|
||||
void testDrawSolidVerticalLine1()
|
||||
{
|
||||
lcdDrawSolidVerticalLine(0, 0, 1, 0);
|
||||
}
|
||||
|
||||
void testDrawSolidVerticalLine2()
|
||||
{
|
||||
lcdDrawSolidVerticalLine(0, 0, LCD_H, 0);
|
||||
}
|
||||
|
||||
void testDrawDiagonalLine()
|
||||
{
|
||||
lcdDrawLine(0,0, LCD_W, LCD_H, SOLID, TEXT_COLOR);
|
||||
}
|
||||
|
||||
void testEmpty()
|
||||
{
|
||||
}
|
||||
|
||||
void testDrawRect()
|
||||
{
|
||||
lcdDrawRect(0, 0, LCD_W, LCD_H, 2, SOLID, TEXT_COLOR);
|
||||
}
|
||||
|
||||
void testDrawText()
|
||||
{
|
||||
lcdDrawText(0, LCD_H/2, "The quick brown fox jumps over the lazy dog", TEXT_COLOR);
|
||||
}
|
||||
|
||||
void testDrawTextVertical()
|
||||
{
|
||||
lcdDrawText(30, LCD_H, "The quick brown fox ", TEXT_COLOR|VERTICAL|NO_FONTCACHE);
|
||||
}
|
||||
|
||||
void testClear()
|
||||
{
|
||||
lcdClear();
|
||||
}
|
||||
|
||||
#define GRAPHICS_TEST_RUN_STEP 100
|
||||
#define RUN_GRAPHICS_TEST(name, runtime) runGraphicsTest(name, #name, runtime)
|
||||
|
||||
float runGraphicsTest(graphichTestFunc func, const char * name, uint32_t runtime)
|
||||
{
|
||||
uint32_t start = (uint32_t)CoGetOSTime();
|
||||
uint32_t noRuns = 0;
|
||||
while (((uint32_t)CoGetOSTime() - start) < runtime/2 ) {
|
||||
for (int n=0; n<GRAPHICS_TEST_RUN_STEP; n++) {
|
||||
func();
|
||||
}
|
||||
lcdRefresh();
|
||||
noRuns += GRAPHICS_TEST_RUN_STEP;
|
||||
}
|
||||
uint32_t actualRuntime = (uint32_t)CoGetOSTime() - start;
|
||||
float result = (noRuns * 500.0f) / (float)actualRuntime; // runs/second
|
||||
serialPrint("Test %s speed: %0.2f, (%d runs in %d ms)", name, result, noRuns, actualRuntime*2);
|
||||
CoTickDelay(100);
|
||||
return result;
|
||||
}
|
||||
|
||||
int cliTestGraphics()
|
||||
{
|
||||
serialPrint("Starting graphics performance test...");
|
||||
CoTickDelay(100);
|
||||
|
||||
watchdogSuspend(6000/*60s*/);
|
||||
if (pulsesStarted()) {
|
||||
pausePulses();
|
||||
}
|
||||
pauseMixerCalculations();
|
||||
perMainEnabled = false;
|
||||
|
||||
float result = 0;
|
||||
RUN_GRAPHICS_TEST(testEmpty, 1000);
|
||||
// result += RUN_GRAPHICS_TEST(testDrawSolidHorizontalLine1, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawSolidHorizontalLine2, 1000);
|
||||
// result += RUN_GRAPHICS_TEST(testDrawSolidVerticalLine1, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawSolidVerticalLine2, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawDiagonalLine, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawSolidFilledRectangle, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawSolidFilledRoundedRectangle, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawRect, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawFilledRectangle, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawBlackOverlay, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawText, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testDrawTextVertical, 1000);
|
||||
result += RUN_GRAPHICS_TEST(testClear, 1000);
|
||||
|
||||
serialPrint("Total speed: %0.2f", result);
|
||||
|
||||
perMainEnabled = true;
|
||||
if (pulsesStarted()) {
|
||||
resumePulses();
|
||||
}
|
||||
resumeMixerCalculations();
|
||||
watchdogSuspend(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void memoryRead(const uint8_t * src, uint32_t size)
|
||||
{
|
||||
// uint8_t data;
|
||||
while(size--) {
|
||||
/*data =*/ *(const uint8_t volatile *)src;
|
||||
++src;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void memoryRead(const uint32_t * src, uint32_t size)
|
||||
{
|
||||
while(size--) {
|
||||
*(const uint32_t volatile *)src;
|
||||
++src;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t * testbuff[100];
|
||||
|
||||
void memoryCopy(uint8_t * dest, const uint8_t * src, uint32_t size)
|
||||
{
|
||||
while(size--) {
|
||||
*dest = *src;
|
||||
++src;
|
||||
++dest;
|
||||
}
|
||||
}
|
||||
|
||||
void memoryCopy(uint32_t * dest, const uint32_t * src, uint32_t size)
|
||||
{
|
||||
while(size--) {
|
||||
*dest = *src;
|
||||
++src;
|
||||
++dest;
|
||||
}
|
||||
}
|
||||
|
||||
#define MEMORY_SPEED_BLOCK_SIZE (4*1024)
|
||||
|
||||
void testMemoryReadFrom_RAM_8bit()
|
||||
{
|
||||
memoryRead((const uint8_t *)cliLastLine, MEMORY_SPEED_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
void testMemoryReadFrom_RAM_32bit()
|
||||
{
|
||||
memoryRead((const uint32_t *)0x20000000, MEMORY_SPEED_BLOCK_SIZE/4);
|
||||
}
|
||||
|
||||
void testMemoryReadFrom_SDRAM_8bit()
|
||||
{
|
||||
memoryRead((const uint8_t *)0xD0000000, MEMORY_SPEED_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
void testMemoryReadFrom_SDRAM_32bit()
|
||||
{
|
||||
memoryRead((const uint32_t *)0xD0000000, MEMORY_SPEED_BLOCK_SIZE/4);
|
||||
}
|
||||
|
||||
extern uint8_t * LCD_FIRST_FRAME_BUFFER;
|
||||
extern uint8_t * LCD_SECOND_FRAME_BUFFER;
|
||||
|
||||
|
||||
void testMemoryCopyFrom_RAM_to_SDRAM_32bit()
|
||||
{
|
||||
memoryCopy((uint32_t *)LCD_FIRST_FRAME_BUFFER, (const uint32_t * )cliLastLine, MEMORY_SPEED_BLOCK_SIZE/4);
|
||||
}
|
||||
|
||||
void testMemoryCopyFrom_RAM_to_SDRAM_8bit()
|
||||
{
|
||||
memoryCopy((uint8_t *)LCD_FIRST_FRAME_BUFFER, (const uint8_t * )cliLastLine, MEMORY_SPEED_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
void testMemoryCopyFrom_SDRAM_to_SDRAM_32bit()
|
||||
{
|
||||
memoryCopy((uint32_t *)LCD_FIRST_FRAME_BUFFER, (const uint32_t * )LCD_SECOND_FRAME_BUFFER, MEMORY_SPEED_BLOCK_SIZE/4);
|
||||
}
|
||||
|
||||
void testMemoryCopyFrom_SDRAM_to_SDRAM_8bit()
|
||||
{
|
||||
memoryCopy((uint8_t *)LCD_FIRST_FRAME_BUFFER, (const uint8_t * )LCD_SECOND_FRAME_BUFFER, MEMORY_SPEED_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
#define MEMORY_TEST_RUN_STEP 100
|
||||
#define RUN_MEMORY_TEST(name, runtime) runMemoryTest(name, #name, runtime)
|
||||
|
||||
float runMemoryTest(graphichTestFunc func, const char * name, uint32_t runtime)
|
||||
{
|
||||
uint32_t start = (uint32_t)CoGetOSTime();
|
||||
uint32_t noRuns = 0;
|
||||
while (((uint32_t)CoGetOSTime() - start) < runtime/2 ) {
|
||||
for (int n=0; n<MEMORY_TEST_RUN_STEP; n++) {
|
||||
func();
|
||||
}
|
||||
noRuns += MEMORY_TEST_RUN_STEP;
|
||||
}
|
||||
uint32_t actualRuntime = (uint32_t)CoGetOSTime() - start;
|
||||
float result = (noRuns * 500.0f) / (float)actualRuntime; // runs/second
|
||||
serialPrint("Test %s speed: %0.2f, (%d runs in %d ms)", name, result, noRuns, actualRuntime*2);
|
||||
CoTickDelay(100);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int cliTestMemorySpeed()
|
||||
{
|
||||
serialPrint("Starting memory speed test...");
|
||||
CoTickDelay(100);
|
||||
|
||||
watchdogSuspend(6000/*60s*/);
|
||||
if (pulsesStarted()) {
|
||||
pausePulses();
|
||||
}
|
||||
pauseMixerCalculations();
|
||||
perMainEnabled = false;
|
||||
|
||||
float result = 0;
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200);
|
||||
|
||||
LTDC_Cmd(DISABLE);
|
||||
serialPrint("Disabling LCD...");
|
||||
CoTickDelay(100);
|
||||
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200);
|
||||
|
||||
serialPrint("Total speed: %0.2f", result);
|
||||
|
||||
LTDC_Cmd(ENABLE);
|
||||
|
||||
perMainEnabled = true;
|
||||
if (pulsesStarted()) {
|
||||
resumePulses();
|
||||
}
|
||||
resumeMixerCalculations();
|
||||
watchdogSuspend(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // #if defined(COLORLCD)
|
||||
|
||||
int cliTest(const char ** argv)
|
||||
{
|
||||
if (!strcmp(argv[1], "new")) {
|
||||
|
@ -354,6 +644,14 @@ int cliTest(const char ** argv)
|
|||
else if (!strcmp(argv[1], "std::exception")) {
|
||||
serialPrint("Not implemented");
|
||||
}
|
||||
#if defined(COLORLCD)
|
||||
else if (!strcmp(argv[1], "graphics")) {
|
||||
return cliTestGraphics();
|
||||
}
|
||||
else if (!strcmp(argv[1], "memspd")) {
|
||||
return cliTestMemorySpeed();
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
serialPrint("%s: Invalid argument \"%s\"", argv[0], argv[1]);
|
||||
}
|
||||
|
@ -956,7 +1254,7 @@ const CliCommand cliCommands[] = {
|
|||
{ "set", cliSet, "<what> <value>" },
|
||||
{ "stackinfo", cliStackInfo, "" },
|
||||
{ "meminfo", cliMemoryInfo, "" },
|
||||
{ "test", cliTest, "new | std::exception" },
|
||||
{ "test", cliTest, "new | std::exception | graphics | memspd" },
|
||||
{ "trace", cliTrace, "on | off" },
|
||||
#if defined(PCBFLAMENCO)
|
||||
{ "read_bq24195", cliReadBQ24195, "<register>" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue