[MLton] commit r4241: First cut at fixing -codegen c -profile
time
Matthew Fluet
fluet@cs.cornell.edu
Fri, 18 Nov 2005 08:38:24 -0500 (EST)
>> [fluet@localhost native]$ mlprof -thresh 2.0 hamlet mlmon.out
>> 25.98 seconds of CPU time (4.54 seconds GC)
>> function cur
>> --------------------------- -----
>> <gc> 14.9%
>> Sequence.Slice.collate.loop 12.7%
>
> Just out of interest: what is Sequence.Slice.collate.loop doing? Something
> to do with string comparison?
Yes. The Sequence functor gives a single implementation for the uniform
behavior of arrays and vectors. It's Slice sub-structure is the
implementation of slices on arbitrary sequences. collate is lexicographic
order, and loop is the actual loop through the sequences after computing
the min and max indices of the slices.
Walking back up the other way, Sequence.collate is simply implemented by
Sequence.Slice.collate on full slices. CharVector{,Slice} is an
instantiation of the Sequence functor, and String.compare is
CharVector.collate Char.compare.
Functors are a little annoying with regards to profiling, since you might
really want to see which instantiation of the functor. (Though, this is
arguably a MLton-ism, in the sense that each instantiation really has it's
own code and is profiled separately. Other implementations might not be
able to break out functor instantiations for profiling.)