mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
clean up voxel server stats page
This commit is contained in:
parent
03b2ace488
commit
f12064c647
1 changed files with 50 additions and 30 deletions
|
@ -108,36 +108,74 @@ int VoxelServer::civetwebRequestHandler(struct mg_connection* connection) {
|
|||
const struct mg_request_info* ri = mg_get_request_info(connection);
|
||||
|
||||
if (strcmp(ri->uri, "/") == 0 && strcmp(ri->request_method, "GET") == 0) {
|
||||
uint64_t checkSum;
|
||||
// return a 200
|
||||
mg_printf(connection, "%s", "HTTP/1.0 200 OK\r\n\r\n");
|
||||
mg_printf(connection, "%s", "Your Voxel Server is running.\r\n");
|
||||
mg_printf(connection, "%s", "Current Statistics\r\n");
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
mg_printf(connection, "Voxel Node Memory Usage: %8.2f MB\r\n", VoxelNode::getVoxelMemoryUsage() / 1000000.f);
|
||||
mg_printf(connection, "Octcode Memory Usage: %8.2f MB\r\n", VoxelNode::getOctcodeMemoryUsage() / 1000000.f);
|
||||
mg_printf(connection, "External Children Memory Usage: %8.2f MB\r\n",
|
||||
VoxelNode::getExternalChildrenMemoryUsage() / 1000000.f);
|
||||
|
||||
const char* memoryScaleLabel;
|
||||
const float MEGABYTES = 1000000.f;
|
||||
const float GIGABYTES = 1000000000.f;
|
||||
float memoryScale;
|
||||
if (VoxelNode::getTotalMemoryUsage() / MEGABYTES < 1000.0f) {
|
||||
memoryScaleLabel = "MB";
|
||||
memoryScale = MEGABYTES;
|
||||
} else {
|
||||
memoryScaleLabel = "GB";
|
||||
memoryScale = GIGABYTES;
|
||||
}
|
||||
|
||||
mg_printf(connection, "Voxel Node Memory Usage: %8.2f %s\r\n",
|
||||
VoxelNode::getVoxelMemoryUsage() / memoryScale, memoryScaleLabel);
|
||||
mg_printf(connection, "Octcode Memory Usage: %8.2f %s\r\n",
|
||||
VoxelNode::getOctcodeMemoryUsage() / memoryScale, memoryScaleLabel);
|
||||
mg_printf(connection, "External Children Memory Usage: %8.2f %s\r\n",
|
||||
VoxelNode::getExternalChildrenMemoryUsage() / memoryScale, memoryScaleLabel);
|
||||
mg_printf(connection, "%s", " -----------\r\n");
|
||||
mg_printf(connection, " Total: %8.2f MB\r\n", VoxelNode::getTotalMemoryUsage() / 1000000.f);
|
||||
mg_printf(connection, " Total: %8.2f %s\r\n",
|
||||
VoxelNode::getTotalMemoryUsage() / memoryScale, memoryScaleLabel);
|
||||
|
||||
mg_printf(connection, "\r\nVoxelNode size... %ld bytes\r\n", sizeof(VoxelNode));
|
||||
|
||||
unsigned long nodeCount = VoxelNode::getNodeCount();
|
||||
unsigned long internalNodeCount = VoxelNode::getInternalNodeCount();
|
||||
unsigned long leafNodeCount = VoxelNode::getLeafNodeCount();
|
||||
|
||||
|
||||
QLocale locale(QLocale::English);
|
||||
|
||||
const float AS_PERCENT = 100.0;
|
||||
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
mg_printf(connection, "%s", "Current Nodes in scene\r\n");
|
||||
mg_printf(connection, " Total Nodes: %10.lu nodes\r\n", nodeCount);
|
||||
mg_printf(connection, " Internal Nodes: %10.lu nodes (%5.2f%%)\r\n",
|
||||
internalNodeCount, ((float)internalNodeCount/(float)nodeCount) * AS_PERCENT);
|
||||
mg_printf(connection, " Leaf Nodes: %10.lu nodes (%5.2f%%)\r\n",
|
||||
leafNodeCount, ((float)leafNodeCount/(float)nodeCount) * AS_PERCENT);
|
||||
mg_printf(connection, " Total Nodes: %s nodes\r\n",
|
||||
locale.toString((uint)nodeCount).rightJustified(16, ' ').toLocal8Bit().constData());
|
||||
mg_printf(connection, " Internal Nodes: %s nodes (%5.2f%%)\r\n",
|
||||
locale.toString((uint)internalNodeCount).rightJustified(16, ' ').toLocal8Bit().constData(),
|
||||
((float)internalNodeCount/(float)nodeCount) * AS_PERCENT);
|
||||
mg_printf(connection, " Leaf Nodes: %s nodes (%5.2f%%)\r\n",
|
||||
locale.toString((uint)leafNodeCount).rightJustified(16, ' ').toLocal8Bit().constData(),
|
||||
((float)leafNodeCount/(float)nodeCount) * AS_PERCENT);
|
||||
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
mg_printf(connection, "%s", "VoxelNode Children Population Statistics...\r\n");
|
||||
checkSum = 0;
|
||||
for (int i=0; i <= NUMBER_OF_CHILDREN; i++) {
|
||||
checkSum += VoxelNode::getChildrenCount(i);
|
||||
mg_printf(connection, " Nodes with %d children: %s nodes (%5.2f%%)\r\n", i,
|
||||
locale.toString((uint)VoxelNode::getChildrenCount(i)).rightJustified(16, ' ').toLocal8Bit().constData(),
|
||||
((float)VoxelNode::getChildrenCount(i)/(float)nodeCount) * AS_PERCENT);
|
||||
}
|
||||
mg_printf(connection, "%s", " ----------------------\r\n");
|
||||
mg_printf(connection, " Total: %s nodes\r\n",
|
||||
locale.toString((uint)checkSum).rightJustified(16, ' ').toLocal8Bit().constData());
|
||||
|
||||
#ifdef BLENDED_UNION_CHILDREN
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
mg_printf(connection, "%s", "VoxelNode Children Encoding Statistics...\r\n");
|
||||
|
||||
#ifdef BLENDED_UNION_CHILDREN
|
||||
mg_printf(connection, " Single or No Children: %10.llu nodes (%5.2f%%)\r\n",
|
||||
VoxelNode::getSingleChildrenCount(), ((float)VoxelNode::getSingleChildrenCount()/(float)nodeCount) * AS_PERCENT);
|
||||
mg_printf(connection, " Two Children as Offset: %10.llu nodes (%5.2f%%)\r\n",
|
||||
|
@ -152,38 +190,20 @@ int VoxelServer::civetwebRequestHandler(struct mg_connection* connection) {
|
|||
mg_printf(connection, " Three Children as External: %10.llu nodes (%5.2f%%)\r\n",
|
||||
VoxelNode::getThreeChildrenExternalCount(),
|
||||
((float)VoxelNode::getThreeChildrenExternalCount()/(float)nodeCount) * AS_PERCENT);
|
||||
#endif
|
||||
mg_printf(connection, " Children as External Array: %10.llu nodes (%5.2f%%)\r\n",
|
||||
VoxelNode::getExternalChildrenCount(),
|
||||
((float)VoxelNode::getExternalChildrenCount()/(float)nodeCount) * AS_PERCENT);
|
||||
|
||||
#ifdef BLENDED_UNION_CHILDREN
|
||||
uint64_t checkSum = VoxelNode::getSingleChildrenCount() +
|
||||
checkSum = VoxelNode::getSingleChildrenCount() +
|
||||
VoxelNode::getTwoChildrenOffsetCount() + VoxelNode::getTwoChildrenExternalCount() +
|
||||
VoxelNode::getThreeChildrenOffsetCount() + VoxelNode::getThreeChildrenExternalCount() +
|
||||
VoxelNode::getExternalChildrenCount();
|
||||
#else
|
||||
uint64_t checkSum = VoxelNode::getExternalChildrenCount();
|
||||
#endif
|
||||
|
||||
mg_printf(connection, "%s", " ----------------\r\n");
|
||||
mg_printf(connection, " Total: %10.llu nodes\r\n", checkSum);
|
||||
mg_printf(connection, " Expected: %10.lu nodes\r\n", nodeCount);
|
||||
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
mg_printf(connection, "%s", "VoxelNode Children Population Statistics...\r\n");
|
||||
checkSum = 0;
|
||||
for (int i=0; i <= NUMBER_OF_CHILDREN; i++) {
|
||||
checkSum += VoxelNode::getChildrenCount(i);
|
||||
mg_printf(connection, " Nodes with %d children: %10.llu nodes (%5.2f%%)\r\n", i,
|
||||
VoxelNode::getChildrenCount(i), ((float)VoxelNode::getChildrenCount(i)/(float)nodeCount) * AS_PERCENT);
|
||||
}
|
||||
mg_printf(connection, "%s", " ----------------\r\n");
|
||||
mg_printf(connection, " Total: %10.llu nodes\r\n", checkSum);
|
||||
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
|
||||
#ifdef BLENDED_UNION_CHILDREN
|
||||
mg_printf(connection, "%s", "In other news....\r\n");
|
||||
mg_printf(connection, "could store 4 children internally: %10.llu nodes\r\n",
|
||||
VoxelNode::getCouldStoreFourChildrenInternally());
|
||||
|
|
Loading…
Reference in a new issue