Reputation: 4355
I'm doing a library that makes extensive use of a thread local variable. Can you point to some benchmarks that test the performances of the different ways to get thread local variables in C++:
Does C++0x thread_local performs much better on the compilers providing it?
Upvotes: 10
Views: 365
Reputation: 269
These are typically implemented as a simple offset in an array in the thread's private memory space. So, accessing the thread specific variable X
, of type T
,
T y = X;
roughly translates to,
T y = *(T*)(cur_thread.local_tbl[key_X]);
which is too simple to expect a wide variation in performance between implementations. That said, if you find any such benchmarks, please follow up here.
Upvotes: 1
Reputation:
You can always use time.h
. Its your friend when testing performance stuff and nothing else is available.
Upvotes: 1