DocumentCode
2043026
Title
Refactor conditionals into polymorphism: what´s the performance cost of introducing virtual calls?
Author
Demeyer, Serge
Author_Institution
Lab. on Reengineering, Antwerp Univ., Belgium
fYear
2005
fDate
26-29 Sept. 2005
Firstpage
627
Lastpage
630
Abstract
The notion of refactoring - transforming the source-code of an object-oriented program without changing its external behavior - has been embraced by many object-oriented software developers as a way to accommodate changing requirements. If applied well, refactoring improves the maintainability of the software. However, it is believed that it does so at the sake of performance. Especially in a C++ context, the introduction of virtual function calls is often blamed for performance reduction because it introduces an extra indirection via the so-called virtual function table. To investigate the performance trade-off involved when introducing virtual functions, we compared the execution time of four benchmark programs which contain large conditionals against refactored versions where the conditionals were replaced by virtual function calls. Depending on the compiler and compiler optimizations being used, we discovered that C++ programs refactored this way often perform faster than their non-refactored counterparts, hence advise programmers not to obfuscate their programs with conditional logic in order to obtain good performance.
Keywords
C++ language; object-oriented programming; software maintenance; software performance evaluation; C++ program refactoring; compiler optimization; conditional refactoring; object-oriented program; object-oriented software development; polymorphism; software maintainability; software performance cost; source-code transformation; virtual function call; virtual function table; Costs; Logic; Optimizing compilers; Power generation; Program processors; Programming profession; Software maintenance; Software performance; Software reusability; Software systems;
fLanguage
English
Publisher
ieee
Conference_Titel
Software Maintenance, 2005. ICSM'05. Proceedings of the 21st IEEE International Conference on
ISSN
1063-6773
Print_ISBN
0-7695-2368-4
Type
conf
DOI
10.1109/ICSM.2005.74
Filename
1510160
Link To Document