Skip to content

Instantly share code, notes, and snippets.

@yushulx
Created July 22, 2020 01:28
Show Gist options
  • Save yushulx/f8c85554ed7c24204185679a97318305 to your computer and use it in GitHub Desktop.
Save yushulx/f8c85554ed7c24204185679a97318305 to your computer and use it in GitHub Desktop.
const auto processor_count = std::thread::hardware_concurrency();
int minimum_count = 1, minimum_timecost = 0;
for (int i = 0; i < processor_count; i++)
{
printf("Thread count: %d. ", i + 1);
int timecost = barcode_decoding(buffer, size, formats, i, license, config);
if (i == 0)
{
minimum_count = 1;
if (timecost > 0)
{
minimum_timecost = timecost;
}
}
else {
if (timecost < minimum_timecost)
{
minimum_count = i + 1;
minimum_timecost = timecost;
}
}
}
printf("Multi-thread best performance: thread_count = %d, timecost = %d \n\n", minimum_count, minimum_timecost);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment