[Haskell-cafe] Slow IO

Daniel Fischer daniel.is.fischer at web.de
Sat Sep 9 20:17:48 EDT 2006

Hello all,
Now I have an IO-problem, too.
SPOJ problem 41 asks basically to determine whether a directed graph allows a 
path that uses every edge exactly once. The data from which the graphs are to 
be constructed are contained in a (huge) file, every item (number of test 
cases, size of test case, edges) on a single line. I've created my own test 
case file (much smaller, but already 217 MB, 2.2 million lines) to check my 
programme's performance. Now profiling reveals that over 90% of time and 
allocation are consumed by reading the file (line by line, reading the whole 
file as a lazy String and then chopping that to pieces is rather worse).

So how do I quickly 
1. read an Integer n from the file,
2. read the next n lines and
3. pass the first and last letter of those to the function that builds and 
checks the graph?

When that is achieved, I could see whether my algorithm is good.

Thanks for any help,

"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
	-- Blair P. Houghton

More information about the Haskell-Cafe mailing list