Skip to content

Commit

Permalink
Resolve issue sync time in CPU average.
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsmagd committed Aug 26, 2024
1 parent 2109fd4 commit 4aa28fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions Ifnity/Ifnity/src/Ifnity/Layers/NVML_Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ struct AverageCircularBuffer
}
}

void clear() { data.clear(); }

T average() { return totValue / data.size(); }
};

Expand All @@ -104,17 +106,17 @@ class IFNITY_API NVML_Monitor :public Layer
m_nvmlMonitor = std::make_unique<NvmlMonitor>(SAMPLING_INTERVAL, SAMPLING_NUM);
#endif


glm::vec3 color = { 0.0f, 0.0f, 0.0f };
addSettingsHandler();
}
~NVML_Monitor() {};

void ConnectToEventBusImpl(void* bus) {};

void OnAttach() override
{
glm::vec3 color = { 0.0f, 0.0f, 0.0f };
addSettingsHandler();


s_refreshRate = ImGui::GetTime();
}


Expand Down Expand Up @@ -158,11 +160,13 @@ class IFNITY_API NVML_Monitor :public Layer
const NvmlMonitor::SysInfo& cpuMeasure = m_nvmlMonitor->getSysInfo();

{ // Averaging the CPU sampling, but limit the
static double s_refreshRate = ImGui::GetTime();
if ((ImGui::GetTime() - s_refreshRate) > SAMPLING_INTERVAL / 1000.0)
// static double s_refreshRate = ImGui::GetTime();
if ((ImGui::GetTime() - s_refreshRate ) > SAMPLING_INTERVAL / 1000.0)
{
m_avgCpu.addValue(cpuMeasure.cpu[m_nvmlMonitor->getOffset()]);
s_refreshRate = ImGui::GetTime();


}
}

Expand Down Expand Up @@ -1164,6 +1168,7 @@ class IFNITY_API NVML_Monitor :public Layer
#if defined(NVP_SUPPORTS_NVML)
std::unique_ptr<NvmlMonitor> m_nvmlMonitor;
AverageCircularBuffer<float> m_avgCpu = { SAMPLING_NUM };
inline static double s_refreshRate{ 0 };
#endif

};
Expand Down
4 changes: 2 additions & 2 deletions Ifnity/Sandbox/src/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ class ImGuiTestLayer : public IFNITY::Layer


IFNITY::App::GetApp()
.SetGraphicsAPI(GraphicsAPI::OPENGL,api == GraphicsAPI::OPENGL);
.SetGraphicsAPI(GraphicsAPI::OPENGL,api != GraphicsAPI::OPENGL);
break;
case 1:
// Acción para la opción 2
IFNITY_LOG(LogApp, INFO, "D3D11");
IFNITY::App::GetApp()
.SetGraphicsAPI(GraphicsAPI::D3D11, api == GraphicsAPI::D3D11);
.SetGraphicsAPI(GraphicsAPI::D3D11, api != GraphicsAPI::D3D11);
break;
default:
IFNITY_LOG(LogApp, INFO, "No option ");
Expand Down

0 comments on commit 4aa28fa

Please sign in to comment.