TITLE: Sample performance numbers for virtual and inline [ This material comes from "C++ Strategies and Tactics" by Robert B. Murry, p. 131 ] As an experiment, I built an abvious String class that used an underlying char* representation. All the member functions were small (one to five lines). I then built a program that sorted an array of ten Strings. On three different platforms, I timed a version that had every member function statically bound, but without using any inlines; a version that had every member function except the constructors dynamically bound (virtual); and a version that used virtual functions and a trivial derivation from a virtual base class. The optimizer was turned on in all cases. [The table below] has the results, with all times normalized to the time it took for the version that used the inline functions. Platform/Compiler Inline No Inline Virtual V. Base Sparc10/USL C++3.0 1 1.05 1.07 1.10 SGI 4D/USL C++ 3.0 1 1.06 1.08 1.13 IBM386X/Borland C++3.0 1 1.10 1.13 1.21 Design for inheritance can have a significant effect on programs that use the class heavily. [...] You should not pay this cost unless there is some benefit. On the other hand, the performance impact is not so great that you should warp your designs to avoid the use of virtual functions and/or virtual base classes.