next up previous contents index
Next: Exceptions Up: User Guide Previous: Using GMP   Contents   Index

Profiling

libaldor provides a couple of tools to help you determine how much time is spent in various sections of your programs. The simplest way is to use the TIMESTART and TIME(...) macros in your code. Those macros have absolutely no effect when compiling normally, but if you add the option -dTIME in the compiler command line when making the .ao file, then a CPU stopwatch is started when TIMESTART is encountered, and read at each TIME(...) statement. Those readings are then written to stderr together with whatever message appears inside the TIME macro. For example, if a computation has 3 major parts, then the following coding allows you to determine how much time is spent in each part:
myComputation(...):... == {
    TIMESTART;                  -- has no effect on normal compilation
    ... part 1 of the computation ...
    TIME("myComputation: part one done at");
    ... part 2 of the computation ...
    TIME("myComputation: part two done at");
    ... part 3 of the computation ...
    TIME("myComputation: part three done at");
    ...                         -- do not forget to return the result here
}
When profiling sections of a multi-file library, simply recompile the desired .as files with the -dTIME -fo -q3 options, then link your executable with the local .o files, which takes precedence over the ones in the library.

Finer profiling, including obtaining information on the garbage collection time, is possible via the use of the type Timer, whose elements are stopwatches that can be started and stopped at will. See the reference section for more information on the use of timers.


next up previous contents index
Next: Exceptions Up: User Guide Previous: Using GMP   Contents   Index
Manuel Bronstein 2004-06-28