Skip to content

Commit

Permalink
Be more lenient in thread performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson committed Jul 28, 2022
1 parent f97c574 commit 83e39ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ doc/html
doc/doxygen_sqlite3.db
build
.DS_Store
include/DSPatchVersion.h
include/DSPatchVersion.h
.vscode/settings.json
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

13 changes: 9 additions & 4 deletions tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Circuit>();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down

0 comments on commit 83e39ef

Please sign in to comment.