The Wisdom of Time

Ketil Z Malde ketil@ii.uib.no
07 Jan 2002 14:03:57 +0100


Keith Wansbrough <Keith.Wansbrough@cl.cam.ac.uk> writes:

>> what is the wisdom behind representing a TimeDiff as a struct of year,
>> month, week and so on, instead of simply the (fractional) number of
>> seconds, or similar?

> Firstly, I believe that the Time module is broken, and no one has yet
> come up with a satisfactory design.

Okay.

> But the behaviour you describe is necessary.  Consider:

Right, thanks for the elaboration.  What is the right way to calculate
the time an operation takes?  I thought just doing

	do
	t1 <- getClockTime
	putStrLn (show $ resultOfComputation)
	t2 <- getClockTime
	putStrLn (show $ diffClockTimes t2 t1)

which seems to work well enough for my purposes.

(I'd like to measure running times for various algorithms on various
data sets, at the moment mainly to convince myself about time
complexity, but perhaps later to compare against implementations on
different compilers/languages.  I could of course simply use
/usr/bin/time, but it seems a bit of a hassle to compile each
benchmark individually to do so.)

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants