mirror of
https://github.com/wqking/eventpp.git
synced 2024-12-27 16:41:11 +08:00
2.7 KiB
2.7 KiB
Benchmarks
CallbackList invoking VS native function invoking
Hardware: Intel(R) Xeon(R) CPU E3-1225 V2 @ 3.20GHz
Software: Windows 10, MSVC 2017, MinGW GCC 7.2.0
Iterations: 100,000,000
Time unit: milliseconds
Function | Compiler | Native invoking | CallbackList single threading | CallbackList multi threading |
---|---|---|---|---|
Inline global function | MSVC 2017 | 217 | 1501 | 6921 |
GCC 7.2 | 187 | 1489 | 4463 | |
Non-inline global function | MSVC 2017 | 241 | 1526 | 6544 |
GCC 7.2 | 233 | 1488 | 4787 | |
Function object | MSVC 2017 | 194 | 1498 | 6433 |
GCC 7.2 | 212 | 1485 | 4951 | |
Member virtual function | MSVC 2017 | 207 | 1533 | 6558 |
GCC 7.2 | 212 | 1485 | 4489 | |
Member non-virtual function | MSVC 2017 | 214 | 1533 | 6390 |
GCC 7.2 | 211 | 1486 | 4872 | |
Member non-inline virtual function | MSVC 2017 | 206 | 1522 | 6578 |
GCC 7.2 | 182 | 1666 | 4593 | |
Member non-inline non-virtual function | MSVC 2017 | 206 | 1491 | 6992 |
GCC 7.2 | 205 | 1486 | 4490 | |
All functions | MSVC 2017 | 1374 | 10951 | 29973 |
GCC 7.2 | 1223 | 9770 | 22958 |
Testing functions
#if defined(_MSC_VER)
#define NON_INLINE __declspec(noinline)
#else
// gcc
#define NON_INLINE __attribute__((noinline))
#endif
volatile int globalValue = 0;
void globalFunction(int a, const int b)
{
globalValue += a + b;
}
NON_INLINE void nonInlineGlobalFunction(int a, const int b)
{
globalValue += a + b;
}
struct FunctionObject
{
void operator() (int a, const int b)
{
globalValue += a + b;
}
virtual void virFunc(int a, const int b)
{
globalValue += a + b;
}
void nonVirFunc(int a, const int b)
{
globalValue += a + b;
}
NON_INLINE virtual void nonInlineVirFunc(int a, const int b)
{
globalValue += a + b;
}
NON_INLINE void nonInlineNonVirFunc(int a, const int b)
{
globalValue += a + b;
}
};
#undef NON_INLINE