Oberon_Command said:
That matches my expectations as well - I expect most of the perf loss to be related to the allocations.
Sure, but I was still suprised to see pretty much a 0% overhead on call (I expected at least a bit, due to having to go through the type-erasure => though maybe this part is just heavily optimized at the cost of memory/allocation speed in the implementation that I tested). Also, I was suprised by the amount of overhead due to the deallocation caused by the captureless variant. Sure, it has to allocate/deallocate the type-erasure container, but I expected it to be a lot smarter about how it would handle a simple member-to-function pointer with no capture. Would be interesting to see how other implementations fair.
taby said:
Using the Release build, the numbers are close, but not quite the same: Function pointer method took 1.42315 seconds Function<> method took 1.97452 seconds
Which compiler did you test this on? Would also be interested in seeing to code to compare it to what I've done previously.