Optimization with C++ Template
C++ template can be used for enabling optimization. For example, you have a function: void foo(int x){ // ... int v = n / x; // slow division operation // ... } And call it. foo(16); Let’s assume foo...
View ArticleNon-alignment integer access performance
When you define a structure like this, the integer field is allocated not just after the byte field, but aligned to 4 byte boundary. struct foo{ unsigned char v1; unsigned int v2;}; It’s because x86...
View ArticleWin32 native monitor is much faster than boost
Windows Vista (finally!) introduced APIs to build a monitor object.http://msdn2.microsoft.com/en-us/library/ms683469.aspx So, how’s performance? Let’s benchmark it. I wrote two bounded FIFO classes....
View ArticleUse IO Completion port to implement thread safe FIFO
Here is an example to implement thread safe FIFO using IO Completion port as a queue implementation. The implementation assumes there is only on thread pushing and another thread pulling. /*! A thread...
View ArticleCondition variables performance of boost, Win32, and the C++11 standard library
About four years ago, I wrote the condition variables in Win32 API was much faster than boost threading library implementation. Since then the boost threading library has been rewritten and C++11 has...
View Article