I tried to create a heap memory profile for the following naive Haskell code that copies the file:
import System.Environment
import System.IO
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as LB
naiveCopy :: String -> String -> IO ()
naiveCopy from to = do
putStrLn $ "From: " ++ from
putStrLn $ "To: " ++ to
s <- B.readFile from
B.writeFile to s
main = do
args <- getArgs
mapM (\ x-> putStrLn x) args
naiveCopy (head args) ((head.tail) args)
The command that creates the code using ghc 8.0.1:
ghc -o t -rtsopts -prof -fprof-auto t.hs
A command that collects profiling data:
./t +RTS -p -h -RTS in/data out/data && hp2ps -e8in -c t.hp
where in/datais a rather large file (about 500 MB), which will take about 2 seconds to copy the program.
The problem is that I could not get the heap profiling data, if I use strict , there will be only a small t.hp file without any sample data, it looks like this: Data.ByteString
JOB "t in/data out/data +RTS -p -h"
DATE "Thu Aug 4 20:19 2016"
SAMPLE_UNIT "seconds"
VALUE_UNIT "bytes"
BEGIN_SAMPLE 0.000000
END_SAMPLE 0.000000
BEGIN_SAMPLE 0.943188
END_SAMPLE 0.943188
and the corresponding profile diagram:

, Data.ByteString.Lazy, :

: @ryachza, -i0, , ByteString ( 500 500 ).
./t +RTS -p -h -RTS in/data out/data && hp2ps -e8in -c t.hp
