1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830
|
% This file was created automatically from debug.msk.
% DO NOT EDIT!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%W debug.msk GAP manual Thomas Breuer
%W Alexander Hulpke
%W Martin Schoenert
%%
%H @(#)$Id: debug.msk,v 1.25 2003/10/12 08:58:48 gap Exp $
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Chapter{Debugging and Profiling Facilities}
This chapter describes some functions that are useful mainly for
debugging and profiling purposes.
The sections~"ApplicableMethod" and~"Tracing Methods" show how to get
information about the methods chosen by the method selection mechanism
(see chapter~"prg:Method Selection" in the programmer's manual).
The final sections describe functions for collecting statistics about
computations (see "Runtime", "Profiling").
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Recovery from NoMethodFound-Errors}
When the method selection fails because there is no applicable method, an
error as in the following example occurs and a break loop is entered:
%notest
\beginexample
gap> IsNormal(2,2);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `IsNormal' on 2 arguments called from
<function>( <arguments> ) called from read-eval-loop
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk>
\endexample
This only says, that the method selection tried to find a method for
`IsNormal' on two arguments and failed. In this situation it is
crucial to find out, why this happened. Therefore there are a few functions
which can display further information.
Note that you can leave the break loop by the `quit' command (see~"quit")
and that the information about the incident is no longer accessible
afterwards.
%If you use `return' you have to supply a method
%which matches.
\>ShowArguments( ) F
This function is only available within a break loop caused by a ``No
Method Found''-error. It prints as a list the arguments of the operation
call for which no method was found.
%% `ShowArguments' can
%% be called with any number of arguments. They are ignored.
\>ShowArgument( <nr> ) F
This function is only available within a break loop caused by a ``No
Method Found''-error. It prints the <nr>-th arguments of the operation call
for which no method was found. `ShowArgument' needs exactly one
argument which is an integer between 0 and the number of arguments the
operation was called with.
\>ShowDetails( ) F
This function is only available within a break loop caused by a ``No
Method Found''-error. It prints the details of this error: The
operation, the number of arguments, a flag which indicates whether the
operation is being traced, a flag which indicates whether the
operation is a constructor method, and the number of methods that
refused to apply by calling `TryNextMethod'. The last number is called
`Choice' and is printed as an ordinal. So if exactly $k$ methods were
found but called `TryNextMethod' and there were no more methods it says
`Choice: $k$th'.
\>ShowMethods( ) F
\>ShowMethods( <verbosity> ) F
This function is only available within a break loop caused by a ``No
Method Found''-error. It prints an overview about the installed methods
for those arguments the operation was called with (using
`ApplicableMethod', see "ApplicableMethod"). The verbosity can be
controlled by the optional integer parameter <verbosity>. The default
is 2, which lists all applicable methods. With verbosity 1
`ShowMethods' only shows the number of installed methods and the
methods matching, which can only be those that were already called but
refused to work by calling `TryNextMethod'. With verbosity 3 not only
all installed methods but also the reasons why they do not match are
displayed.
\>ShowOtherMethods( ) F
\>ShowOtherMethods( <verbosity> ) F
This function is only available within a break loop caused by a ``No
Method Found''-error. It prints an overview about the installed methods
for a different number of arguments than the number of arguments the
operation was called with (using `ApplicableMethod', see
"ApplicableMethod"). The verbosity can be controlled by the optional
integer parameter <verbosity>. The default is 1 which lists only the
number of applicable methods. With verbosity 2 `ShowOtherMethods' lists
all installed methods and with verbosity 3 also the reasons, why they
are not applicable. Calling `ShowOtherMethods' with verbosity 3 in this
function will normally not make any sense, because the different
numbers of arguments are simulated by supplying the corresponding
number of ones, for which normally no reasonable methods will be
installed.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{ApplicableMethod}\nolabel
\>ApplicableMethod( <opr>, <args> [, <printlevel> ] ) F
\>ApplicableMethod( <opr>, <args>, <printlevel>, <nr> ) F
\>ApplicableMethod( <opr>, <args>, <printlevel>, "all" ) F
\>ApplicableMethodTypes( <opr>, <args> [, <printlevel> ] ) F
\>ApplicableMethodTypes( <opr>, <args>, <printlevel>, <nr> ) F
\>ApplicableMethodTypes( <opr>, <args>, <printlevel>, "all" ) F
In the first form, `ApplicableMethod' returns the method of highest rank
that is applicable for the operation <opr> with the arguments in the
list <args>.
The default <printlevel> is `0'.
If no method is applicable then `fail' is returned.
In the second form, if <nr> is a positive integer then
`ApplicableMethod' returns the <nr>-th applicable method for the
operation <opr> with the arguments in the list <args>, where the methods
are ordered according to descending rank. If less than <nr> methods are
applicable then `fail' is returned.
If the fourth argument is the string `"all"' then `ApplicableMethod'
returns a list of all applicable methods for <opr> with arguments
<args>, ordered according to descending rank.
Depending on the integer value <printlevel>, additional information is
printed. Admissible values and their meaning are as follows.
\beginlist
\item{0}
no information,
\item{1}
information about the applicable method,
\item{2}
also information about the not applicable methods of higher rank,
\item{3}
also for each not applicable method the first reason why it is not
applicable,
\item{4}
also for each not applicable method all reasons why it is not
applicable.
\item{6}
also the function body of the selected method(s)
\endlist
When a method returned by `ApplicableMethod' is called then it returns
either the desired result or the string `TRY_NEXT_METHOD', which
corresponds to a call to `TryNextMethod' in the method and means that
the method selection would call the next applicable method.
*Note:* The kernel provides special treatment for the infix operations
`\\+', `\\-', `\\*', `\\/', `\\^', `\\mod' and `\\in'. For some kernel
objects (notably cyclotomic numbers, finite field elements and vectors
thereof) it calls kernel methods circumventing the method selection
mechanism. Therefore for these operations `ApplicableMethod' may return
a method which is not the kernel method actually used.
`ApplicableMethod' does not work for constructors (for example
`GeneralLinearGroupCons' is a constructor).
The function `ApplicableMethodTypes' takes the *types* or *filters* of
the arguments as argument (if only filters are given of course family
predicates cannot be tested).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Tracing Methods}
\>TraceMethods( <oprs> ) F
After the call of `TraceMethods' with a list <oprs> of operations,
whenever a method of one of the operations in <oprs> is called the
information string used in the installation of the method is printed.
\>UntraceMethods( <oprs> ) F
turns the tracing off for all operations in <oprs>.
\beginexample
gap> TraceMethods( [ Size ] );
gap> g:= Group( (1,2,3), (1,2) );;
gap> Size( g );
#I Size: for a permutation group
#I Setter(Size): system setter
#I Size: system getter
#I Size: system getter
6
gap> UntraceMethods( [ Size ] );
\endexample
\>TraceImmediateMethods( <flag> ) F
If <flag> is true, tracing for all immediate methods is turned on.
If <flag> is false it is turned off.
(There is no facility to trace *specific* immediate methods.)
\beginexample
gap> TraceImmediateMethods( true );
gap> g:= Group( (1,2,3), (1,2) );;
#I immediate: Size
#I immediate: IsCyclic
#I immediate: IsCommutative
#I immediate: IsTrivial
#I immediate: IsStabChainViaChainSubgroup
#I immediate: IsChainTypeGroup
gap> Size( g );
#I immediate: IsNonTrivial
#I immediate: Size
#I immediate: IsStabChainViaChainSubgroup
#I immediate: IsChainTypeGroup
#I immediate: IsNonTrivial
#I immediate: GeneralizedPcgs
#I immediate: IsPerfectGroup
#I immediate: IsEmpty
6
gap> TraceImmediateMethods( false );
gap> UntraceMethods( [ Size ] );
\endexample
This example gives an explanation for the two calls of the
``system getter'' for `Size'.
Namely, there are immediate methods that access the known size
of the group.
Note that the group `g' was known to be finitely generated already
before the size was computed,
the calls of the immediate method for `IsFinitelyGeneratedGroup'
after the call of `Size' have other arguments than `g'.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Info Functions}
The `Info' mechanism permits operations to display intermediate results or
information about the progress of the algorithms.
Information is always given according to one or more *info classes*. Each of the
info classes defined in the {\GAP} library usually covers a certain range
of algorithms, so for example `InfoLattice' covers all the cyclic extension
algorithms for the computation of a subgroup lattice.
The amount of information to be displayed can be specified by the user for
each info class separately by a *level*, the higher the level the more
information will be displayed.
Ab initio all info classes have level zero except `InfoWarning'
(see~"InfoWarning") which initially has level 1.
\>NewInfoClass( <name> ) O
creates a new info class with name <name>.
\>DeclareInfoClass( <name> ) F
creates a new info class with name <name> and binds it to the global
variable <name>. The variable must previously be writable, and is made
readonly by this function.
\>SetInfoLevel( <infoclass>, <level> ) O
Sets the info level for <infoclass> to <level>.
\>InfoLevel( <infoclass> ) O
returns the info level of <infoclass>.
\>Info( <infoclass>, <level>, <info> [,<moreinfo> . . .] )
If the info level of <infoclass> is at least <level> the remaining
arguments (<info> and possibly <moreinfo> and so on) are evaluated and
viewed, preceded by '\#I ' and followed by a newline. Otherwise the
third and subsequent arguments are not evaluated. (The latter can save
substantial time when displaying difficult results.)
\beginexample
gap> InfoExample:=NewInfoClass("InfoExample");;
gap> Info(InfoExample,1,"one");Info(InfoExample,2,"two");
gap> SetInfoLevel(InfoExample,1);
gap> Info(InfoExample,1,"one");Info(InfoExample,2,"two");
#I one
gap> SetInfoLevel(InfoExample,2);
gap> Info(InfoExample,1,"one");Info(InfoExample,2,"two");
#I one
#I two
gap> InfoLevel(InfoExample);
2
gap> Info(InfoExample,3,Length(Combinations([1..9999])));
\endexample
Note that the last `Info' call is executed without problems,
since the actual level `2' of `InfoExample' causes `Info' to ignore
the last argument, which prevents `Length(Combinations([1..9999]))'
from being evaluated;
note that an evaluation would be impossible due to memory restrictions.
A set of info classes (called an *info selector*) may be passed to a
single `Info' statement. As a shorthand, info classes and selectors
may be combined with `+' rather than `Union'. In this case, the
message is triggered if the level of *any* of the classes is high enough.
\beginexample
gap> InfoExample:=NewInfoClass("InfoExample");;
gap> SetInfoLevel(InfoExample,0);
gap> Info(InfoExample + InfoWarning, 1, "hello");
#I hello
gap> Info(InfoExample + InfoWarning, 2, "hello");
gap> SetInfoLevel(InfoExample,2);
gap> Info(InfoExample + InfoWarning, 2, "hello");
#I hello
gap> InfoLevel(InfoWarning);
1
\endexample
\>`InfoWarning' V
is an info class to which general warnings are sent at level 1, which is
its default level. More specialised warnings are `Info'-ed at `InfoWarning'
level 2, e.g.~information about the autoloading of {\GAP} packages and the
initial line matched when displaying an on-line help topic.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Assertions}
Assertions are used to find errors in algorithms.
They test whether intermediate results conform to required conditions
and issue an error if not.
\>SetAssertionLevel( <lev> ) F
assigns the global assertion level to <lev>. By default it is zero.
\>AssertionLevel() F
returns the current assertion level.
\>Assert( <lev>, <cond> ) F
\>Assert( <lev>, <cond>, <message> ) F
With two arguments, if the global assertion level is at least <lev>,
condition <cond> is tested and if it does not return `true' an error is
raised.
Thus `Assert(lev, <cond>)' is equivalent to the code
\begintt
if AssertionLevel() >= lev and not <cond> then
Error("Assertion failure");
fi;
\endtt
With the <message> argument form of the `Assert' statement, if the global
assertion level is at least <lev>, condition <cond> is tested and if it
does not return `true' then <message> is evaluated and printed.
Assertions are used at various places in the library.
Thus turning assertions on can slow code execution significantly.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Timing}
\>Runtimes() F
`Runtimes' returns a record with components bound to integers or `fail'.
Each integer
is the cpu time (processor time) in milliseconds spent by {\GAP} in a
certain status:
\beginlist
\item{}`user\_time'\ \ cpu time spent with {\GAP} functions (without child
processes).
\item{}`system\_time'\ \ cpu time spent in system calls, e.g., file access
(`fail' if not available).
\item{}`user\_time\_children'\ \ cpu time spent in child processes (`fail' if not available).
\item{}`system\_time\_children'\ \ cpu time spent in system calls by child
processes (`fail' if not available).
\endlist
Note that this function is not fully supported on all systems. Only the
`user\_time' component is (and may on some systems include the system
time).
The following example demonstrates tasks which contribute to the different
time components:
\begintt
gap> Runtimes(); # after startup
rec( user_time := 3980, system_time := 60, user_time_children := 0,
system_time_children := 0 )
gap> Exec("cat /usr/bin/*||wc"); # child process with a lot of file access
893799 7551659 200928302
gap> Runtimes();
rec( user_time := 3990, system_time := 60, user_time_children := 1590,
system_time_children := 600 )
gap> a:=0;;for i in [1..100000000] do a:=a+1; od; # GAP user time
gap> Runtimes();
rec( user_time := 12980, system_time := 70, user_time_children := 1590,
system_time_children := 600 )
gap> ?blabla # first call of help, a lot of file access
Help: no matching entry found
gap> Runtimes();
rec( user_time := 13500, system_time := 440, user_time_children := 1590,
system_time_children := 600 )
\endtt
\>Runtime() F
`Runtime' returns the time spent by {\GAP} in milliseconds as an integer.
It is the same as the value of the `user\_time' component given by `Runtimes',
as explained above.
See `StringTime' ("StringTime") for a translation from milliseconds into
hour/minute format.
\>`time;'{time}@{`time'}
in the read-eval-print loop returns the time the last command took.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Profiling}
Profiling of code can be used to determine in which parts of a program how
much time has been spent during runtime.
\>ProfileOperations( [<true/false>] ) F
When called with argument <true>, this function starts profiling of all
operations.
Old profiling information is cleared.
When called with <false> it stops profiling of all operations.
Recorded information is still kept,
so you can display it even after turning the profiling off.
When called without argument, profiling information for all profiled
operations is displayed (see~"DisplayProfile").
\>ProfileOperationsAndMethods( [<true/false>] ) F
When called with argument <true>, this function starts profiling of all
operations and their methods.
Old profiling information is cleared.
When called with <false> it stops profiling of all operations and their
methods.
Recorded information is still kept,
so you can display it even after turning the profiling off.
When called without argument, profiling information for all profiled
operations and their methods is displayed (see~"DisplayProfile").
\>ProfileMethods( <ops> ) F
starts profiling of the methods for all operations in <ops>.
\>UnprofileMethods( <ops> ) F
stops profiling of the methods for all operations in <ops>. Recorded
information is still kept, so you can display it even after turning the
profiling off.
\>ProfileFunctions( <funcs> ) F
turns profiling on for all function in <funcs>. You can use
`ProfileGlobalFunctions' (see~"ProfileGlobalFunctions") to turn
profiling on for all globally declared functions simultaneously.
\>UnprofileFunctions( <funcs> ) F
turns profiling off for all function in <funcs>. Recorded information is
still kept, so you can display it even after turning the profiling off.
\>ProfileGlobalFunctions( true ) F
\>ProfileGlobalFunctions( false ) F
`ProfileGlobalFunctions(true)' turns on profiling for all functions that
have been declared via `DeclareGlobalFunction'. A function call with the
argument `false' turns it off again.
\>DisplayProfile( ) F
\>DisplayProfile( <funcs> ) F
In the first form, `DisplayProfile' displays the profiling information
for profiled operations, methods and functions. If an argument
<funcs> is given, only profiling information for the functions in
<funcs> is given. The information for a profiled function is only
displayed if the number of calls to the function or the total time spent
in the function exceeds a given threshold (see~"PROFILETHRESHOLD").
Profiling information is displayed in a list of lines for all functions
(also operations and methods) which are profiled. For each function,
``count'' gives the number of times the function has been called.
``self'' gives the time spent in the function itself, ``child'' the time
spent in profiled functions called from within this function.
The list is sorted according to the total time spent, that is the sum
``self''+``child''.
\>`PROFILETHRESHOLD' V
This variable is a list $[<cnt>,<time>]$ of length two. `DisplayProfile'
will only display lines for functions which are called at least <cnt>
times or whose *total* time (``self''+``child'') is at least <time>.
The default value of `PROFILETHRESHOLD' is [10000,30].
\>ClearProfile( ) F
clears all stored profiling information.
%notest
\beginexample
gap> ProfileOperationsAndMethods(true);
gap> ConjugacyClasses(PrimitiveGroup(24,1));;
gap> ProfileOperationsAndMethods(false);
gap> DisplayProfile();
count self/ms chld/ms function
[the following is excerpted from a much longer list]
1620 170 90 CycleStructurePerm: default method
1620 20 260 CycleStructurePerm
114658 280 0 Size: for a list that is a collection
287 20 290 Meth(CyclesOp)
287 0 310 CyclesOp
26 0 330 Size: for a conjugacy class
2219 50 380 Size
2 0 670 IsSubset: for two collections (loop over the ele*
32 0 670 IsSubset
48 10 670 IN: for a permutation, and a permutation group
2 20 730 Meth(ClosureGroup)
2 0 750 ClosureGroup
1 0 780 DerivedSubgroup
1 0 780 Meth(DerivedSubgroup)
4 0 810 Meth(StabChainMutable)
29 0 810 StabChainOp
3 700 110 Meth(StabChainOp)
1 0 820 Meth(IsSimpleGroup)
1 0 820 Meth(IsSimple)
552 10 830 Meth(StabChainImmutable)
26 490 480 CentralizerOp: perm group,elm
26 0 970 Meth(StabilizerOfExternalSet)
107 0 970 CentralizerOp
926 10 970 Meth(CentralizerOp)
819 2100 2340 Meth(IN)
1 10 4890 ConjugacyClasses: by random search
1 0 5720 ConjugacyClasses: perm group
2 0 5740 ConjugacyClasses
6920 TOTAL
gap> DisplayProfile(StabChainOp,DerivedSubgroup); # only two functions
count self/ms chld/ms function
1 0 780 DerivedSubgroup
29 0 810 StabChainOp
6920 OTHER
6920 TOTAL
\endexample
Note that profiling (even the command `ProfileOperationsAndMethods(true)')
can take substantial time and {\GAP} will perform much more slowly
when profiling than when not.
\>DisplayCacheStats( ) F
displays statistics about the different caches used by the method
selection.
\>ClearCacheStats( ) F
clears all statistics about the different caches used by the method
selection.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Information about the version used}
\>DisplayRevision( ) F
Displays the revision numbers of all loaded files from the library.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Test Files}
Test files are used to check that {\GAP} produces correct results in
certain computations. A selection of test files for the library can be
found in the `tst' directory of the {\GAP} distribution.
\>ReadTest( <name-file> ) O
reads a test file.
A test file starts with a line
\begintt
gap> START_TEST("arbitrary identifier string");
\endtt
(Note that the `gap>' prompt is part of the line!)
It continues by lines of {\GAP} input and corresponding output.
The input lines again start with the `gap>' prompt (or the `>' prompt if
commands exceed one line). The output is exactly as would result from typing
in the input interactively to a {\GAP} session
(on a screen with 80 characters per line).
The test file stops with a line
\begintt
gap> STOP_TEST( "filename", 10000 );
\endtt
Here the string `"filename"' should give the name of the test file. The
number is a proportionality factor that is used to output a ``{\GAP}stone''
speed ranking after the file has been completely processed. For the files
provided with the distribution this scaling is roughly equalized to yield
the same numbers as produced by `combinat.tst'.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Debugging Recursion}
The {\GAP} interpreter monitors the level of nesting of {\GAP}
functions during execution. By default, whenever this nesting reaches
a multiple of 5000, {\GAP} enters a break loop ("break loops") allowing
you to terminate the calculation, or enter `return;' to continue it.
%notest
\beginexample
gap> dive:= function(depth) if depth>1 then dive(depth-1); fi; return; end;
function( depth ) ... end
gap> dive(100);
gap> OnBreak:= function() Where(1); end; # shorter traceback
function( ) ... end
gap> dive(6000);
recursion depth trap (5000)
at
dive( depth - 1 );
called from
dive( depth - 1 ); called from
...
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you may 'return;' to continue
brk> return;
gap> dive(11000);
recursion depth trap (5000)
at
dive( depth - 1 );
called from
dive( depth - 1 ); called from
...
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you may 'return;' to continue
brk> return;
recursion depth trap (10000)
at
dive( depth - 1 );
called from
dive( depth - 1 ); called from
...
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you may 'return;' to continue
brk> return;
gap>
\endexample
This behaviour can be controlled using the procedure
\> SetRecursionTrapInterval( <interval> ) F
<interval> must be a non-negative small integer (between 0 and
$2^{28}$). An <interval> of 0 suppresses the monitoring of recursion
altogether. In this case excessive recursion may cause {\GAP} to crash.
%notest
\beginexample
gap> dive:= function(depth) if depth>1 then dive(depth-1); fi; return; end;
function( depth ) ... end
gap> SetRecursionTrapInterval(1000);
gap> dive(2500);
recursion depth trap (1000)
at
dive( depth - 1 );
called from
dive( depth - 1 ); called from
...
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you may 'return;' to continue
brk> return;
recursion depth trap (2000)
at
dive( depth - 1 );
called from
dive( depth - 1 ); called from
...
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you may 'return;' to continue
brk> return;
gap> SetRecursionTrapInterval(-1);
SetRecursionTrapInterval( <interval> ): <interval> must be a non-negative smal\
l integer
not in any function
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can replace <interval> via 'return <interval>;' to continue
brk> return ();
SetRecursionTrapInterval( <interval> ): <interval> must be a non-negative smal\
l integer
not in any function
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can replace <interval> via 'return <interval>;' to continue
brk> return 0;
gap> dive(20000);
gap> dive(2000000);
Segmentation fault
\endexample
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Global Memory Information}
The {\GAP} environment provides automatic memory management, so that
the programmer does not need to concern themselves with allocating
space for objects, or recovering space when objects are no longer
needed. The component of the kernel which provides this is called
`GASMAN' ({\GAP} Storage MANager). Messages reporting garbage
collections performed by GASMAN can be switched on by the `-g' command
line option (see section "command line options"). There are also some
facilities to access information from GASMAN from {\GAP} programs.
\>GasmanStatistics( ) F
`GasmanStatistics()' returns a record containing some information
from the garbage collection mechanism. The record may contain up to
two components: `full' and `partial'
The `full' component will be present if a full garbage collection
has taken place since GAP started. It contains information about
the most recent full garbage collection. It is a record, with six
components: `livebags' contains the number of bags which survived
the garbage collection; `livekb' contains the total number of
kilobytes occupied by those bags; `deadbags' contains the total
number of bags which were reclaimed by that garbage collection and
all the partial garbage collections preceeding it, since the
previous full garbage collection; `deadkb' contains the total
number of kilobytes occupied by those bags; `freekb' reports the
total number of kilobytes available in the GAP workspace for new
objects and `totalkb' the actual size of the workspace.
These figures shouold be viewed with some caution. They are
stored internally in fixed length integer formats, and `deadkb'
and `deadbags' are liable to overflow if there are many partial
collections before a full collection. Also, note that `livekb' and
`freekb' will not usually add up to `totalkb'. The difference is
essentially the space overhead of the memory management system.
The `partial' component will be present if there has been a
partial garbage collection since the last full one. It is also a
record with the same six components as `full'. In this case
`deadbags' and `deadkb' refer only to the number and total size of
the garbage bags reclaimed in this partial garbage collection and
`livebags'and `livekb' only to the numbers and total size of the
young bags that were considered for garbage collection, and
survived.
\>GasmanMessageStatus( ) F
\>SetGasmanMessageStatus( <stat> ) F
`GasmanMessageStatus()' returns one of the string \"none\",
\"full\" or \"all\", depending on whether the garbage collector is
currently set to print messages on no collections, full
collections only or all collections.
`SetGasmanMessageStatus( <stat> )' sets the garbage collector
messaging level. <stat> should be one of the strings \"none\",
\"full\" or \"all\".
\>GasmanLimits( ) F
`GasmanLimits()' returns a record with three components: `min' is
the minimum workspace size as set by the `-m' command line option
in kilobytes. The workspace size will never be reduced below this
by the garbage collector. `max' is the maximum workspace size, as
set by the '-o' command line option, also in kilobytes. If the
workspace would need to grow past this point, GAP will enter a
break loop to warn the user. A value of 0 indicates no
limit.`kill' is the absolute maximum, set by the `-K' command line
option. The workspace will never be allowed to grow past this
limit.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%E
|