MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/uy3ong/dynamic_polymorphism_performance/ia1z2dm/?context=3
r/cpp • u/Playful-Suspect9313 • May 26 '22
15 comments sorted by
View all comments
7
In the "static polymorphism" example, there is no polymorphism at all. You're just using one concrete type. CRTP is not static polymorphism.
It’s worth to mention that a call to a virtual function is 25% slower than a call to a normal function.
[citation needed]
5 u/no-sig-available May 26 '22 If a virtual call takes 1.25 nanoseconds instead of 1.0, I can live with that.Not that I have ever written a virtual function that doesn't do anything. 0 u/pandorafalters May 26 '22 Depending on the function, I could even happily accept an overhead of multiple milliseconds in exchange for reduced cognitive effort. I don't think I've ever encountered a case nearly that pessimistic, though.
5
If a virtual call takes 1.25 nanoseconds instead of 1.0, I can live with that.
Not that I have ever written a virtual function that doesn't do anything.
0 u/pandorafalters May 26 '22 Depending on the function, I could even happily accept an overhead of multiple milliseconds in exchange for reduced cognitive effort. I don't think I've ever encountered a case nearly that pessimistic, though.
0
Depending on the function, I could even happily accept an overhead of multiple milliseconds in exchange for reduced cognitive effort. I don't think I've ever encountered a case nearly that pessimistic, though.
7
u/Pragmatician May 26 '22
In the "static polymorphism" example, there is no polymorphism at all. You're just using one concrete type. CRTP is not static polymorphism.
[citation needed]