Skip to content

Commit

Permalink
Reduce iteration count of cancelation_registration perf test by 10x.
Browse files Browse the repository at this point in the history
The test was taking too long under debug builds.
  • Loading branch information
lewissbaker committed May 7, 2017
1 parent 618ed37 commit fbb2a93
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,11 +1098,6 @@ void testConcurrentRegistrationAndCancellation()

void testCancellationRegistrationPerformanceSingleThreaded()
{
cppcoro::cancellation_source s;

cppcoro::async_mutex m;
m.try_lock();

struct batch
{
batch(cppcoro::cancellation_token t)
Expand Down Expand Up @@ -1130,9 +1125,13 @@ void testCancellationRegistrationPerformanceSingleThreaded()
cppcoro::cancellation_registration r9;
};

cppcoro::cancellation_source s;

constexpr int iterationCount = 100'000;

auto start = std::chrono::high_resolution_clock::now();

for (int i = 0; i < 1'000'000; ++i)
for (int i = 0; i < iterationCount; ++i)
{
cppcoro::cancellation_registration r{ s.token(), [] {} };
}
Expand All @@ -1143,7 +1142,7 @@ void testCancellationRegistrationPerformanceSingleThreaded()

start = end;

for (int i = 0; i < 1'000'000; ++i)
for (int i = 0; i < iterationCount; ++i)
{
batch b{ s.token() };
}
Expand All @@ -1154,7 +1153,7 @@ void testCancellationRegistrationPerformanceSingleThreaded()

start = end;

for (int i = 0; i < 1'000'000; ++i)
for (int i = 0; i < iterationCount; ++i)
{
batch b0{ s.token() };
batch b1{ s.token() };
Expand All @@ -1174,9 +1173,9 @@ void testCancellationRegistrationPerformanceSingleThreaded()
<< std::endl;
};

report("Individual", time1, 1'000'000);
report("Batch10", time2, 10'000'000);
report("Batch50", time3, 50'000'000);
report("Individual", time1, iterationCount);
report("Batch10", time2, 10 * iterationCount);
report("Batch50", time3, 50 * iterationCount);
}

int main(int argc, char** argv)
Expand Down

0 comments on commit fbb2a93

Please sign in to comment.