[GAP Forum] a problem

Stefan Kohl kohl at univlora.edu.al
Mon Dec 7 15:01:11 GMT 2009


Dear Forum,

Vivek Jain asked:

How can I know the time requirement of that a particular program/code  which
> I prepare to run in gap?
>
> Also can I know how much memory will be needed to run a particular code?
>

This depends on what you want to do and what you know about your code and
the
algorithms or methods you use. -- Due to the algorithmic unsolvability of
the halting
problem for Turing machines, there is no algorithm to make such predictions.
This
is nothing GAP-specific, but holds for programs in any programming language
which
permits emulating Turing machines.

If you in fact rather want to know afterwards how long the execution of a
particular code
has taken, you can use

1. the variable `time', whose value is the runtime of the last command in an
interactive
    GAP session in milliseconds,
2. the function `Runtime', which returns the machine time spent so far in
the present
    GAP session, and
3. the function `Runtimes', which returns a record containing more detailed
information,
    see ?Runtimes.

Apart from this, GAP also provides profiling facilities - see ?Profiling.

You can determine the amount of memory used by a given GAP object by the
operation
`MemoryUsage'. Also, you can obtain information related to garbage
collections and the
present size of the GAP workspace -- see ?GasmanStatistics,
?GasmanMessageStatus
and ?GasmanLimits. Independent of this, on most machines, you can determine
the size
of the GAP job by means of the operating system.

Best regards,

    Stefan Kohl


More information about the Forum mailing list