Version française
Home     About     Download     Resources     Contact us    
Browse thread
Functor Performace Question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] Functor Performace Question
> I have a functor related performance issue.
> I have the following collection of modules and types that we are using
> in the implementation of a SAT solver:
> If we implement Nat_priority_queue in the "right" way as
> module Nat_priority_queue = Make_priority_queue (Nat_map)
> Then I pay about a 3% performance penalty over instantiating the functor
> by hand...
> Is there some compiler switch or future version in the works that will
> save me from this?

Basically, no.  There is indeed a small performance penalty associated
with functors, owing to the fact that the functor body is compiled
only once without knowledge of its arguments.  Late specialization of
functors would be nice in the absolute, but would require a major
rework of the OCaml compiler.  This said, a 3% speed penalty is not
too bad --- to me, it's lost in the noise of performance measurement.

Regards,

- Xavier Leroy