Skip to content

Commit

Permalink
TestDirectory: print amounts of memory allocated and gc time
Browse files Browse the repository at this point in the history
  • Loading branch information
stevelinton authored and fingolfin committed Nov 1, 2017
1 parent d9b6e36 commit c404c86
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
28 changes: 24 additions & 4 deletions lib/test.gi
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,24 @@ end);
##

InstallGlobalFunction( "TestDirectory", function(arg)
local basedirs, nopts, opts, files, newfiles, filetimes,
f, c, i, recurseFiles,
startTime, time, testResult, testTotal,
totalTime, STOP_TEST_CPY;
local testTotal, totalTime, totalMem, STOP_TEST_CPY,
basedirs, nopts, opts, testOptions, earlyStop,
showProgress, suppressStatusMessage, exitGAP, c, files,
filetimes, filemems, recurseFiles, f, i, startTime,
startMem, testResult, time, mem, startGcTime, gctime,
totalGcTime, filegctimes, GcTime;

testTotal := true;
totalTime := 0;
totalMem := 0;
totalGcTime := 0;

GcTime := function()
local g;
g := GASMAN_STATS();
return g[1][8] + g[2][8];
end;

STOP_TEST_CPY := STOP_TEST;
STOP_TEST := function(arg) end;

Expand Down Expand Up @@ -609,6 +619,8 @@ InstallGlobalFunction( "TestDirectory", function(arg)

files := [];
filetimes := [];
filemems := [];
filegctimes := [];

recurseFiles := function(dirs, prefix)
local dircontents, testfiles, t, testrecs, shortName, recursedirs, d, subdirs;
Expand Down Expand Up @@ -658,6 +670,8 @@ InstallGlobalFunction( "TestDirectory", function(arg)
fi;

startTime := Runtime();
startMem := TotalMemoryAllocated();
startGcTime := GcTime();
testResult := Test(files[i].name, opts.testOptions);
if not(testResult) and opts.earlyStop then
STOP_TEST := STOP_TEST_CPY;
Expand All @@ -673,8 +687,14 @@ InstallGlobalFunction( "TestDirectory", function(arg)
testTotal := testTotal and testResult;

time := Runtime() - startTime;
mem := TotalMemoryAllocated() - startMem;
gctime := GcTime() - startGcTime;
filetimes[i] := time;
filemems[i] := mem;
filegctimes[i] := gctime;
totalTime := totalTime + time;
totalMem := totalMem + mem;
totalGcTime := totalGcTime + gctime;

if opts.showProgress then
Print( String( time, 8 ), " msec (",String(gctime),"ms GC) and ",
Expand Down
2 changes: 1 addition & 1 deletion src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ UInt Time;

/****************************************************************************
**
*V MemoryAllocated. . . . . . . . . . . global variable 'memory_allocated'
*V MemoryAllocated . . . . . . . . . . . global variable 'memory_allocated'
**
** 'MemoryAllocated' is the global variable 'memory_allocated',
** which is automatically assigned the amount of memory allocated while
Expand Down
5 changes: 1 addition & 4 deletions src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,9 +1251,7 @@ UInt ResizeBag (
#ifdef COUNT_BAGS
/* update the statistics */
InfoBags[type].sizeLive += new_size - old_size;
// InfoBags[type].sizeAll += new_size - old_size;
#endif
// SizeAllBags += new_size - old_size;

const Int diff = WORDS_BAG(new_size) - WORDS_BAG(old_size);

Expand Down Expand Up @@ -1303,8 +1301,7 @@ UInt ResizeBag (
YoungBags += diff;
AllocBags += diff;

/* In this case we increase the total amount allocated by the
difference */
// and increase the total amount allocated by the difference
#ifdef COUNT_BAGS
InfoBags[type].sizeAll += new_size - old_size;
#endif
Expand Down

0 comments on commit c404c86

Please sign in to comment.