From 83e39ef73cb6fc80d7665afb828c2da7473c67b1 Mon Sep 17 00:00:00 2001 From: Marcus Tomlinson Date: Thu, 28 Jul 2022 11:20:55 +0100 Subject: [PATCH] Be more lenient in thread performance tests --- .gitignore | 3 ++- .vscode/settings.json | 3 --- tests/main.cpp | 13 +++++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 64ecd704..f2750aa9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ doc/html doc/doxygen_sqlite3.db build .DS_Store -include/DSPatchVersion.h \ No newline at end of file +include/DSPatchVersion.h +.vscode/settings.json \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 275f22ab..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "C_Cpp.default.cppStandard": "c++17" -} diff --git a/tests/main.cpp b/tests/main.cpp index 26d2c798..791999d4 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -290,7 +290,12 @@ TEST_CASE( "ChangingOutputTest" ) TEST_CASE( "ThreadPerformanceTest" ) { - int const efficiencyThreshold = 80; // expect at least 80% efficiency + int efficiencyThreshold = 75; // expect at least 75% efficiency with 4+ cores + if ( std::thread::hardware_concurrency() < 4 ) + { + float fraction = (float)std::thread::hardware_concurrency() / 4; + efficiencyThreshold *= (int)fraction; + } // Configure a circuit made up of 4 parallel counters, then adjust the thread count auto circuit = std::make_shared(); @@ -798,7 +803,7 @@ TEST_CASE( "ChangingOutputTest2" ) TEST_CASE( "ThreadPerformanceTest2" ) { - int efficiencyThreshold = 80; // expect at least 80% efficiency with 4+ cores + int efficiencyThreshold = 75; // expect at least 75% efficiency with 4+ cores if ( std::thread::hardware_concurrency() < 4 ) { float fraction = (float)std::thread::hardware_concurrency() / 4; @@ -832,7 +837,7 @@ TEST_CASE( "ThreadPerformanceTest2" ) int count = probe->GetCount(); std::cout << "0x Buffer Efficiency (Parallel Mode): " << count / 10 << "%" << std::endl; - REQUIRE( count / 10 >= efficiencyThreshold * 0.7 ); + REQUIRE( count / 10 >= efficiencyThreshold * 0.75 ); // Tick the circuit with 1 thread, and check that no more ticks occurred if ( std::thread::hardware_concurrency() < 1 ) @@ -853,7 +858,7 @@ TEST_CASE( "ThreadPerformanceTest2" ) count = probe->GetCount(); std::cout << "1x Buffer Efficiency (Parallel Mode): " << count / 10 << "%" << std::endl; - REQUIRE( count / 10 >= efficiencyThreshold * 0.7 ); + REQUIRE( count / 10 >= efficiencyThreshold * 0.75 ); // Tick the circuit with 2 threads, and check that more ticks occurred if ( std::thread::hardware_concurrency() < 2 )