[Haskell-cafe] cost of modules

Fawzi Mohamed fmohamed at mac.com
Tue Mar 27 17:10:21 EDT 2007


I decided to cleanup my program by splitting it in different modules.
As I was curious about
the cost of splitting it, or dually the efficiency of the intermodule 
optimization I timed it before and after the split.
These are the results (ghc-6.6.20070129 on Linux AMD64):

Original: 3 Modules with the computational one with an export list

real    0m0.385s
user    0m0.378s
sys     0m0.003s
time:100%

Variant 1: split computational module in 6 submodules without export 
list, kept computational module reexporting the stuff with an export list

real    0m0.467s
user    0m0.464s
sys     0m0.003s
time: 122%

Variant 2: like Variant 1 but removing the old computational module (no 
reexport list) 134%
real    0m0.513s
user    0m0.506s
sys     0m0.003s

All the functions in my modules have type specialized signatures, so 
non-specialization should almost never be an issue.
The module with the Main function was not the exported one.

So 20% speed hit, I had hoped for 0, but it is not unbearable (even if 
my code has to be as fast as possible, this was a very short run), 
probably I will keep it split to have cleaner code.
Not I will have to write an export list for each module a see it the 
things improve, and how much.
If someone has an idea on how else I can improve timings please tell me.

Fawzi


More information about the Haskell-Cafe mailing list