[Haskell-cafe] slow code
dons at galois.com
Tue Jun 16 11:58:58 EDT 2009
> I have included a new and improved version.
> Just to make the comparison a little more reasonable I re-wrote the
> program using ML and ran it with SMLNJ
> eal 0m3.175s
> user 0m0.935s
> sys 0m0.319s
> Here's the compiled haskell (ghc -O2 foo.hs -o foo):
> real 0m16.855s
> user 0m9.724s
> sys 0m0.495s
> I verified to make sure they were both writing valid data files.
> I'm trying to learn how to fish, so I'm truly interested in finding out
> _how_ to optimize using profiling and other such tools.
> Here's the header of the foo.prof file:
> total time = 9.44 secs (472 ticks @ 20 ms)
> total alloc = 2,171,923,916 bytes (excludes profiling overheads)
> 2GB of allocation ??? with a base size of 131k. that seems excessive,
> which gets me back to the , I don't
> think I'm interpreting profiling stuff correctly.
> This line is a little more interesting:
> COST CENTRE MODULE
> no. entries %time %alloc %time %alloc
> main Main
> 178 1 98.7 99.1 98.7 99.1
> So even though getData should be doing all of the allocation, main's
> using a lot of time and effort. I figured it
> was the show's that were slowing things up (how do I get profiling to
> show that detail ?), so I had it output just "\n".
> Well that finishes in no time at all.
> And yea, verily, the output of the .prof file.
> total time = 0.14 secs (7 ticks @ 20 ms)
> total alloc = 65,562,824 bytes (excludes profiling overheads)
> So I guess it's the show's, but I can't seem to find more efficient
> float output.
> FFI to sprintf ? yuch.
Is your SMLNJ using lazy lists? :)
Try hmatrix or uvector.
More information about the Haskell-Cafe