Skip to content

Commit

Permalink
lowest performance metric
Browse files Browse the repository at this point in the history
  • Loading branch information
Kade-github committed May 23, 2024
1 parent cfc8ccf commit 93a8dd6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 17 additions & 1 deletion src/Engine/Objects/2DCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ void Camera2D::Draw()
return;

static float lT = 0;
static int averagedTime = 0;
static int framesDone = 0;
static float fps = 0;
static float lowestFPS = 0;

float ct = glfwGetTime();

Expand All @@ -295,6 +297,16 @@ void Camera2D::Draw()
}
else
fps = framesDone / (ct - lT);
averagedTime++;

if (fps < lowestFPS || lowestFPS == 0)
lowestFPS = fps;

if (averagedTime > 25)
{
averagedTime = 0;
lowestFPS = fps;
}

framesDone++;

Expand All @@ -304,13 +316,17 @@ void Camera2D::Draw()

DrawDebugText("FPS: " + format, glm::vec2(4, _h - 28), 24);

std::string lowestFromat = StringTools::ToTheDecimial(lowestFPS, 0);

DrawDebugText("Lowest FPS: " + lowestFromat, glm::vec2(4, _h - 52), 24);

size_t memoryUsageBytes = getCurrentRSS();

float memUsage = memoryUsageBytes / 1024.0f / 1024.0f;

format = StringTools::ToTheDecimial(memUsage, 2);

DrawDebugText("Memory Allocated: " + format + "MB", glm::vec2(4, _h - 52), 24);
DrawDebugText("Memory Allocated: " + format + "MB", glm::vec2(4, _h - 76), 24);
}

UpdateFramebuffer();
Expand Down
7 changes: 5 additions & 2 deletions src/Game/Data/Structures/Ruins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,10 @@ void Data::Ruins::Create(int x, int z, int y, Data::Chunk& c, Data::Region* r)

for (BlueprintBlock& block : b.blocks)
{
float realY = y - block.y;
r->freePlace(_x + block.x, realY, _z + block.z, block.type);
int realY = y - block.y;
int _xx = _x + block.x;
int _zz = _z + block.z;

r->freePlace(_xx, realY, _zz, block.type);
}
}

0 comments on commit 93a8dd6

Please sign in to comment.