iammilind
iammilind

Reputation: 69988

Does a frequent calls to `QThread::currentThread()` during logging affect the performance significantly?

In my multi-threaded application, with every log I intend to print the thread information. For that, I have to invoke QThread::currentThread()->objectName() every time.

Here is its source code:

QThread* QThread::currentThread() { return QThreadData::current()->thread.loadAcquire(); }

Was wondering if it will affect the overall performance significantly when the logging increases. I don't have a deterministic way to quantify this information myself.

Upvotes: 1

Views: 55

Answers (1)

J-16 SDiZ
J-16 SDiZ

Reputation: 26910

In latest Qt, it is implemented with std::memory_order_acquire. According to the document, "No additional CPU instructions are issued for this synchronization mode" in x86.

Assume you are using this on intel machines, this would be good.

Upvotes: 2

Related Questions