[nhc-users] Space Profiling

Benjamin Fraser fraserb at usq.edu.au
Tue May 10 08:19:55 EDT 2005


Hello,

I wanted to use nhc to profile a simple program but ran into a string of 
errors. The example I present here is one of four small programs I have played
with. This example is from nhc98-1.18 compilied from source, I have played with
the 1.18 and 1.16 binary versions also. I'm using debian 3. The program is:

#####################strict.hs
module Main where

foldl' f e [] = e
foldl' f e (x:xs) = (foldl' f $! f e x) xs

main = print $ foldl' (+) 0 [1..1000]
{-main = print $ foldr (+) 0 [1..1000]-}
#####################strict.hs

With the aim of showing strict.hs would run in constant space as compared to
the commented out version. I compilied and ran the program thus (I know I can
use hmake instead):

$ nhc98 -p -o strict strict.hs

$ ./strict +RTS -p -i25kb -RTS
500500

$ hp2graph strict.hp
Illegal token JOB at 69
Aborted

This is the most common error encountered. Try again:

$ ./strict +RTS -p -i24kb -RTS
500500

$ hp2graph strict.hp
Segmentation fault

Segmentation faults are the second most common error. It is also possible for 
hp2graph to run without error but it produces invalid postscript that cannot 
be viewed. Here are the strict.hp files from each run:

#####################strict 25kb interval
JOB ./strict +RTS -p -i25kb -RTS ;
DATE "Tue May 10 21:45:49 2005
"
PROFILE_PRODUCER
MARK     0.00
SAMPLE 0     0.00
  	344
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 1     0.00
  	356
  <binary_int_op>	8
  <APPLY>	80
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 2     0.00
  	328
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 3     0.00
  	344
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 4     0.00
  	356
  <binary_int_op>	8
  <APPLY>	80
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 5     0.00
  	328
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 6     0.00
  	344
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 7     0.00
;
#####################strict 25kb interval

#####################strict 24kb interval
JOB ./strict +RTS -p -i24kb -RTS ;
DATE "Tue May 10 21:46:40 2005
"
PROFILE_PRODUCER
MARK     0.00
SAMPLE 0     0.00
  	328
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 1     0.00
  	328
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 2     0.00
  	328
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 3     0.00
  	328
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 4     0.00
  	328
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 5     0.00
  	328
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 6     0.00
  	328
  <binary_int_op>	8
  <APPLY>	72
  <Main>	8
  Builtin.primIntFromInteger	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 7     0.00
  	544
  IO.hPutChar:7:30-7:52	12
  <APPLY>	56
  <Main>	8
  Prelude.primIntegerAdd	8
;
MARK     0.00
SAMPLE 8     0.00
;
#####################strict 24kb interval

What am I doing wrong, some option perhaps?

Thanks,
Ben Fraser



More information about the Nhc-users mailing list