Optimizing generics is easy!
José Pedro Magalhães, Stefan Holdermans, Johan Jeuring, Andres Löh

Datatype-generic programming increases program reliability by reducing code duplication and enhancing reusability and modularity. Several generic programming libraries for Haskell have been developed in the past few years. These libraries have been compared in detail with respect to expressiveness, extensibility, typing issues, etc., but performance comparisons have been brief, limited, and preliminary. It is widely believed that generic programs run slower than hand-written code. In this paper we present an extensive benchmark suite for generic functions and analyze the potential for automatic code optimization at compilation time. Our benchmark confirms that generic programs, when compiled with the standard optimization flags of the Glasgow Haskell Compiler (GHC), are substantially slower than their hand-written counterparts. However, we also find that more advanced optimization capabilities of GHC can be used to further optimize generic functions, sometimes achieving the same efficiency as hand-written code.

Download
ACM DL Author-ize serviceOptimizing generics is easy!
José Pedro Magalhães, Stefan Holdermans, Johan Jeuring, Andres Löh
PEPM '10 Proceedings of the 2010 ACM SIGPLAN workshop on Partial evaluation and program manipulation, 2010

Valid XHTML 1.0! Valid CSS!

Andres Löh, 2013-04-26