Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2472 Discussions

Avoid QueryPerformanceFrequency() call in tick_count::interval_t()

Hi all, Every time the tbb::tick_count::interval_t(double sec) constructor is called, the ticks_per_second() method gets called. Inside the ticks_per_second() method, the QueryPerformanceFrequency() function gets called (on Windows targets). All those calls are inefficient, as stated in A simple way to handle his would be to modify the ticks_per_second() method like this, so that the QueryPerformanceFrequency() call is done only the first time : static LARGE_INTEGER qpfreq; int rval = (qpfreq.QuadPart == 0) ? QueryPerformanceFrequency(&qpfreq) : TRUE; instead of : LARGE_INTEGER qpfreq; int rval = QueryPerformanceFrequency(&qpfreq); This way, each time we call condition_variable.wait_for(interval_t(0.1)) for example, we don't get any penalty during interval_t construction. Do you think it would be possible to integrate this tiny modification inside the TBB ? I know it looks like a detail, but it would be useful I think. Thanks a lot. Best regards, Vincent
0 Kudos
0 Replies