If you enter :set +s
in GHCi, then timing and memory info will be printed after the evaluation of every expression.
Example:
Prelude> :set +s
Prelude> sum [1..2^20]
549756338176
it :: (Num a, Enum a) => a
(0.34 secs, 169,197,008 bytes)
Note that this will be the timing of the expression as evaluated in the interpreter, without optimisation, so it won’t necessarily be an accurate measure of how long things take, or even which of two versions of the same code will be faster, in actual compiled code. For that, take a look at the criterion benchmarking library.