[Haskell-cafe] More fun with micro-benchmarks and optimizations. (GHC vs Perl)

Corey O'Connor coreyoconnor at gmail.com
Wed Jul 23 15:37:08 EDT 2008


On Wed, Jul 23, 2008 at 2:23 PM, Justin Bailey <jgbailey at gmail.com> wrote:
> On Wed, Jul 23, 2008 at 11:10 AM, Corey O'Connor <coreyoconnor at gmail.com> wrote:
>> I still have two questions after all this:
>>  - Can I get a Haskell implementation as fast as the Perl?
>>  - What do I need to do to get GHC's profiler to provide me usable
>> information? Telling me that 98% of the time was in "main" is not very
>> enlightening ;-)
>
> Don did a great job answering teh first question. To get better
> profiling information, add "SCC" annotations to your code. That will
> tell you how much time is spent in a particular expression. For your
> main function, take a divide and conquer approach - add SCCs to
> determine what is taking the most time.

I did write a version of SumTiny.hs with SCC annotations:
http://tothepowerofdisco.com/repo/sum_optimization/SumTinyProf.hs
Maybe I'm missing something, but the profiling still gives me poor
results. Here is the results from the profiler (cut down and, no
doubt, with poor post-email formatting):
-------------------------------------------------------------------
COST CENTRE                    %time %alloc

do                              92.8   87.6
regex                            2.8    4.8
add_line                         2.2    0.4
div                              1.1    0.3
readFile                         0.6    6.2


                         individual    inherited
COST CENTRE              %time %alloc   %time %alloc

MAIN
CAF                      0.0    0.0   100.0  100.0
 main                    0.0    0.0   100.0  100.0
  do                    92.8   87.6   100.0  100.0
   show                  0.0    0.0     0.0    0.0
   foldl                 0.0    0.3     0.0    0.3
   add_line              2.2    0.4     6.6    5.9
    regex                2.8    4.8     2.8    4.8
    sum                  0.0    0.1     0.0    0.1
    div                  1.1    0.3     1.1    0.3
    read Double          0.6    0.2     0.6    0.2
   readFile              0.6    6.2     0.6    6.2
-------------------------------------------------------------------

Which tells me the "do" expression that main is equal to is
responsible for 92.8% of the run time. Which really doesn't tell me
anything.

--
-Corey O'Connor


More information about the Haskell-Cafe mailing list