tags:

views:

120

answers:

3

I wrote an application to analyze a log file using haskell. When I run it with the same log file, sometimes it costs 30s, and sometimes costs 20s, the execution time differs by up to 10 seconds.

why is there such a large difference in running time?

+1  A: 

The difference is more than likely caused by other processes that are running at the same time on the system.

Garry Shutler
but I implement the same function use python language, then run the python script, it spent almost the same time, around 20s
yjfuk
How many times have you tested each? Maybe the python one varies the same way, but you just didn't run it enough times to see?
Herms
I tried so many times,but the result was the same
yjfuk
A: 

solution: use python :)

paffnucy
+2  A: 

Try separating the processing time from the file-access time.

Read the entire file into memory, track that time, then process the data in your storage strucutres and track that time separately.

My gut instinct is that the file access is the random contriubtor. Gut instinct is not a good substitution for a profiler.

Kieveli