Page MenuHomePhorge

Sean::function

Authored By
0xseantasker
Sep 14 2024, 11:49 PM
Size
2 KB
Referenced Files
None
Subscribers
None

Sean::function

Given ~the following with the implementations doing a trivial add and mod:
class Base
{
virtual void Call() = 0;
};
class A : public Base
{
void Call() override;
};
class B : public Base
{
void Call() override;
};
I wanted to compare the performance of various call types:
- virtual
- direct member calls
- std::function
- boost::function
- My special implementation of a std function like thing
Results (I think I won):
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 29.23 | 34,216,563.53 | 1.5% | 8.15 | `base->Call()`
| 22.52 | 44,411,239.42 | 1.3% | 6.29 | `a->Call()`
| 19.89 | 50,271,899.86 | 1.3% | 5.56 | `b->Call()`
| 92.78 | 10,778,025.73 | 2.1% | 25.84 | `function &Base::Call, base`
| 86.25 | 11,593,985.80 | 1.3% | 24.09 | `function &A::Call, a`
| 84.72 | 11,803,082.12 | 1.4% | 23.55 | `function &B::Call, b`
| 76.15 | 13,131,281.23 | 1.3% | 21.30 | `boost function &Base::Call, base`
| 69.62 | 14,364,610.56 | 1.3% | 19.48 | `boost function &A::Call, a`
| 69.63 | 14,360,809.72 | 1.4% | 19.44 | `boost function &B::Call, b`
| 29.93 | 33,412,567.43 | 1.8% | 8.33 | `function pointer direct base, &Base::Call `
| 25.07 | 39,891,310.53 | 1.9% | 6.98 | `function pointer direct a, &A::Call`
| 23.73 | 42,142,903.23 | 1.5% | 6.61 | `function pointer direct b, &B::Call`
| 33.88 | 29,519,892.80 | 1.7% | 9.38 | `genericHacks a|b, &A|B::Call`
| 30.45 | 32,840,113.07 | 1.6% | 8.43 | `genericHacks a, &A::Call`
| 31.13 | 32,127,053.17 | 1.8% | 8.60 | `genericHacks b, &B::Call`
| 26.24 | 38,106,875.48 | 1.7% | 7.31 | `genericHacks direct a|b, &A|B::Call`
| 21.21 | 47,157,137.21 | 2.1% | 5.91 | `genericHacks direct a, &A::Call`
| 21.28 | 46,993,349.25 | 2.0% | 5.92 | `genericHacks direct b, &B::Call`
| 33.20 | 30,123,997.49 | 1.8% | 9.28 | `genericHacks direct a|b, &A|B::CallParams`
| 29.74 | 33,629,366.15 | 2.0% | 8.23 | `genericHacks direct a, &A::CallParams`
| 30.87 | 32,392,540.64 | 2.0% | 8.62 | `genericHacks direct b, &B::CallParams`
| 27.36 | 36,549,522.16 | 1.4% | 7.66 | `genericHacks direct a|b, &A|B::CallParams`
| 20.52 | 48,722,650.82 | 2.1% | 5.74 | `genericHacks direct a, &A::CallParams`
| 20.84 | 47,990,124.58 | 1.8% | 5.81 | `genericHacks direct b, &B::CallParams`

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
58346
Default Alt Text
Sean::function (2 KB)

Event Timeline