[PATCH] qbsp: Fix reporting of peak winding memory use
The number reported for peak memory usage by winding_t structs was not accurate, due to just using the sizeof(winding_t) for accounting. Track the _bytes_ used by each type in a separate array. This is pretty much redundant for everything except windings, but it's the simplest way to implement it for now. Also tidied up the verbose memory output a bit - the total column is pretty useless, so just don't print it. Re-align the other columns and special case the "Total" line, as only the "Peak Bytes" value is really interesting. Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
parent
747631223c
commit
d09b5657f2
|
|
@ -30,7 +30,7 @@ const int rgcMemSize[GLOBAL + 1] = {
|
|||
sizeof(byte), sizeof(dclipnode_t), sizeof(dleaf_t),
|
||||
sizeof(unsigned short),
|
||||
sizeof(dedge_t), sizeof(int), sizeof(dmodel_t), sizeof(mapface_t),
|
||||
sizeof(mapbrush_t), sizeof(mapentity_t), sizeof(winding_t),
|
||||
sizeof(mapbrush_t), sizeof(mapentity_t), 1 /* winding_t */,
|
||||
sizeof(face_t),
|
||||
sizeof(plane_t), sizeof(portal_t), sizeof(surface_t), sizeof(node_t),
|
||||
sizeof(brush_t), sizeof(miptex_t), sizeof(wvert_t), sizeof(wedge_t),
|
||||
|
|
|
|||
37
qbsp/util.c
37
qbsp/util.c
|
|
@ -37,6 +37,8 @@
|
|||
static int rgMemTotal[GLOBAL + 1];
|
||||
static int rgMemActive[GLOBAL + 1];
|
||||
static int rgMemPeak[GLOBAL + 1];
|
||||
static int rgMemActiveBytes[GLOBAL + 1];
|
||||
static int rgMemPeakBytes[GLOBAL + 1];
|
||||
|
||||
/*
|
||||
==========
|
||||
|
|
@ -96,8 +98,11 @@ AllocMem(int Type, int cElements, bool fZero)
|
|||
|
||||
rgMemTotal[Type] += cElements;
|
||||
rgMemActive[Type] += cElements;
|
||||
rgMemActiveBytes[Type] += cSize;
|
||||
if (rgMemActive[Type] > rgMemPeak[Type])
|
||||
rgMemPeak[Type] = rgMemActive[Type];
|
||||
if (rgMemActiveBytes[Type] > rgMemPeakBytes[Type])
|
||||
rgMemPeakBytes[Type] = rgMemActiveBytes[Type];
|
||||
|
||||
// Also keep global statistics
|
||||
rgMemTotal[GLOBAL] += cSize;
|
||||
|
|
@ -120,9 +125,12 @@ FreeMem(void *pMem, int Type, int cElements)
|
|||
rgMemActive[Type] -= cElements;
|
||||
if (Type == WINDING) {
|
||||
pMem = (char *)pMem - sizeof(int);
|
||||
rgMemActiveBytes[Type] -= *(int *)pMem;
|
||||
rgMemActive[GLOBAL] -= *(int *)pMem;
|
||||
} else
|
||||
} else {
|
||||
rgMemActiveBytes[Type] -= cElements * rgcMemSize[Type];
|
||||
rgMemActive[GLOBAL] -= cElements * rgcMemSize[Type];
|
||||
}
|
||||
|
||||
free(pMem);
|
||||
}
|
||||
|
|
@ -136,26 +144,25 @@ PrintMem
|
|||
void
|
||||
PrintMem(void)
|
||||
{
|
||||
char *rgszMemTypes[] =
|
||||
{ "BSPEntity", "BSPPlane", "BSPTex", "BSPVertex", "BSPVis",
|
||||
"BSPNode", "BSPTexinfo", "BSPFace", "BSPLight", "BSPClipnode",
|
||||
"BSPLeaf",
|
||||
char *rgszMemTypes[] = {
|
||||
"BSPEntity", "BSPPlane", "BSPTex", "BSPVertex", "BSPVis", "BSPNode",
|
||||
"BSPTexinfo", "BSPFace", "BSPLight", "BSPClipnode", "BSPLeaf",
|
||||
"BSPMarksurface", "BSPEdge", "BSPSurfedge", "BSPModel", "Mapface",
|
||||
"Mapbrush",
|
||||
"Mapentity", "Winding", "Face", "Plane", "Portal", "Surface", "Node",
|
||||
"Brush",
|
||||
"Miptex", "World verts", "World edges", "Hash verts", "Other (bytes)",
|
||||
"Total (bytes)"
|
||||
"Mapbrush", "Mapentity", "Winding", "Face", "Plane", "Portal",
|
||||
"Surface", "Node", "Brush", "Miptex", "World verts", "World edges",
|
||||
"Hash verts", "Other", "Total"
|
||||
};
|
||||
int i;
|
||||
|
||||
if (options.fVerbose) {
|
||||
Message(msgLiteral,
|
||||
"\nData type Current Peak Total Peak Bytes\n");
|
||||
for (i = 0; i <= GLOBAL; i++)
|
||||
Message(msgLiteral, "%-16s %8d %8d %10d %9d\n", rgszMemTypes[i],
|
||||
rgMemActive[i], rgMemPeak[i], rgMemTotal[i],
|
||||
rgMemPeak[i] * rgcMemSize[i]);
|
||||
"\nData type CurrentNum PeakNum PeakMem\n");
|
||||
for (i = 0; i <= OTHER; i++)
|
||||
Message(msgLiteral, "%-16s %9d %9d %12d\n",
|
||||
rgszMemTypes[i], rgMemActive[i], rgMemPeak[i],
|
||||
rgMemPeakBytes[i]);
|
||||
Message(msgLiteral, "%-16s %12d\n",
|
||||
rgszMemTypes[GLOBAL], rgMemPeak[GLOBAL]);
|
||||
} else
|
||||
Message(msgLiteral, "Bytes used: %d\n", rgMemPeak[GLOBAL]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue