Abstract
Programs capable of generating code are known as meta-programs and the technique of writing these programs is known as meta programming Meta programming is supported by various programming languages such as C#, where reflection is used; Ruby allows defining classes and methods at runtime using meta-programming; the first language to introduce the concept of meta-programming was LISP. The meta-programs written using these languages are generally parsers, theorem proofs and interpreters. In this paper, we’ll be demonstrating the use of meta-programming in C++ through template meta-programming (TMP). We pick up common mathematical operations, creating a run time code of them along with a compile time based equivalent code done through TMP. The two set of codes are then benchmarked on the basis of their execution time and a bar-graph is generated to compare the TMP and non-TMP programs.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Abrahams, D., Gurtovoy, A.: C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond, Portable Documents. Pearson Education, London (2004)
Czarnecki, K., Eisenecker, U.W.: Generative Programming: Methods, Tools and Applications. Addison-Wesley, Boston (2000)
Porkoláb, Z., Mihalicza, J., Sipos, Á.: Debugging C++ template metaprograms. In: Proceedings of the 5th International Conference on Generative Programming and Component Engineering (2006)
Teodorescu, L.R., Dumitrel, V., Potolea, R.: Moving computations from run-time to compile-time: hyper-metaprogramming in practice. In: Proceedings of the 11th ACM Conference on Computing Frontiers. ACM (2014)
Vandevoorde, D., Josuttis, N.M.: C++ Templates: The Complete Guide. Addison-Wesley, Boston (2003)
Sorting Algorithms Animation showing efficiency of different algorithms on different types of data sets (n.d.). https://www.toptal.com/developers/sorting-algorithms
Isensee, P.: Fast math using template metaprogramming. In: Game Programming Gems, pp. 20–34. Charles River Media Inc. (2003)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer Nature Singapore Pte Ltd.
About this paper
Cite this paper
Patel, V., Mishra, P., Patni, J.C., Mittal, P. (2018). Comparison of Runtime Performance Optimization Using Template-Metaprogramming. In: Bhattacharyya, P., Sastry, H., Marriboyina, V., Sharma, R. (eds) Smart and Innovative Trends in Next Generation Computing Technologies. NGCT 2017. Communications in Computer and Information Science, vol 827. Springer, Singapore. https://doi.org/10.1007/978-981-10-8657-1_11
Download citation
DOI: https://doi.org/10.1007/978-981-10-8657-1_11
Published:
Publisher Name: Springer, Singapore
Print ISBN: 978-981-10-8656-4
Online ISBN: 978-981-10-8657-1
eBook Packages: Computer ScienceComputer Science (R0)