1#############################################################################
2##
3##  This file is part of GAP, a system for computational discrete algebra.
4##  This file's authors include Steve Linton.
5##
6##  Copyright of GAP belongs to its developers, whose names are too numerous
7##  to list here. Please refer to the COPYRIGHT file for details.
8##
9##  SPDX-License-Identifier: GPL-2.0-or-later
10##
11##  This file contains implementations of functions that report information from the
12##  GASMAN garbage collector
13##
14#############################################################################
15##
16#F  GasmanStatistics( )
17##
18
19InstallGlobalFunction(GasmanStatistics,
20        function()
21    local raw,cooked,convertrow;
22    raw := GASMAN_STATS();
23    cooked := rec();
24    convertrow := row ->
25                  rec( livebags := row[1],
26                       livekb := row[2],
27                       deadbags := row[3],
28                       deadkb := row[4],
29                       freekb := row[5],
30                       totalkb := row[6],
31                       time := row[7],
32                       cumulative := row[8]);
33    if raw[1][1] <> 0 then
34        cooked.partial := convertrow(raw[1]);
35    fi;
36    if raw[2][1] <> 0 then
37        cooked.full := convertrow(raw[2]);
38    fi;
39    cooked.npartial := raw[1][9];
40    cooked.nfull := raw[2][9];
41    return cooked;
42end );
43
44#############################################################################
45##
46#F  GasmanMessageStatus()
47##
48InstallGlobalFunction(GasmanMessageStatus,
49        function()
50    local stat;
51    stat := GASMAN_MESSAGE_STATUS();
52    if stat = 0 then
53        return "none";
54    elif stat = 1 then
55        return "full";
56    else
57        return "all";
58    fi;
59end );
60
61
62#############################################################################
63##
64#F  SetGasmanMessageStatus( <status> )
65##
66
67InstallGlobalFunction(SetGasmanMessageStatus,
68        function(stat)
69    local oldstat,newstat,i;
70    oldstat := GASMAN_MESSAGE_STATUS();
71    newstat := Position(["none", "full", "all"], stat);
72    if newstat = fail then
73        Error("GASMAN message status must be none, full or all");
74    fi;
75    newstat := newstat -1;
76    for i in [1..(newstat + 3 - oldstat) mod 3] do
77        GASMAN("message");
78    od;
79    return;
80end);
81
82#############################################################################
83##
84#F  GasmanLimits( )
85##
86
87InstallGlobalFunction(GasmanLimits,
88        function()
89    local raw;
90    raw := GASMAN_LIMITS();
91    return rec(min := raw[1],
92               max := raw[2],
93               kill := raw[3]);
94end);
95