<A HREF="manual_c.htm"><img align=center src="contents.gif" ALT="Contents"></A> Up Previous Next

Print statistics +s,-s


Normally, Hugs just shows the result of evaluating each expression:
 Prelude> map (\x -> x*x) [1..10]
 [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
 Prelude> [1..]
 [1, 2, 3, 4, {Interrupted!}
 Prelude>
With the +s option, the interpreter will also display statistics about the total number of reductions and cells; the former gives a measure of the work done, while the latter gives an indication of the amount of memory used. For example:
 Prelude> :set +s
 Prelude> map (\x -> x*x) [1..10]
 [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
 (248 reductions, 429 cells)
 Prelude> [1..]
 [1, 2, 3, 4, {Interrupted!}
 (18 reductions, 54 cells)
 Prelude>
Note that the statistics produced by +s are an extremely crude measure of the behaviour of a program, and can easily be misinterpreted. For example: One reasonable use of the statistics produced by +s would be to observe general trends in the behaviour of a single algorithm with variations in its input.