FastTimer cleanup

This commit is contained in:
Amos 2022-04-05 11:33:37 +02:00
parent f4b263b412
commit 7724e06d3f
3 changed files with 33 additions and 38 deletions

View File

@ -460,8 +460,8 @@ void _RTech_Decompress_f_CompletionFunc(const CCommand& args)
DevMsg(eDLL_T::RTECH, "______________________________________________________________\n");
DevMsg(eDLL_T::RTECH, "] HEADER_DETAILS ---------------------------------------------\n");
DevMsg(eDLL_T::RTECH, "] Magic : '%08X'\n", rheader->m_nMagic);
DevMsg(eDLL_T::RTECH, "] Version : '%u'\n", (rheader->m_nVersion));
DevMsg(eDLL_T::RTECH, "] Flags : '%04X'\n", (flags));
DevMsg(eDLL_T::RTECH, "] Version : '%u'\n", rheader->m_nVersion);
DevMsg(eDLL_T::RTECH, "] Flags : '%04X'\n", flags);
DevMsg(eDLL_T::RTECH, "] Hash : '%llu'\n", rheader->m_nHash);
DevMsg(eDLL_T::RTECH, "] Entries : '%zu'\n", rheader->m_nAssetEntryCount);
DevMsg(eDLL_T::RTECH, "______________________________________________________________\n");
@ -482,7 +482,7 @@ void _RTech_Decompress_f_CompletionFunc(const CCommand& args)
}
if (rheader->m_nSizeDisk != upak.size())
{
Error(eDLL_T::RTECH, "Error: pak file '%s' decompressed size '%u' doesn't match expected value '%u'!\n", pakNameIn.c_str(), upak.size(), rheader->m_nSizeMemory);
Error(eDLL_T::RTECH, "Error: pak file '%s' decompressed size '%zu' doesn't match expected value '%zu'!\n", pakNameIn.c_str(), upak.size(), rheader->m_nSizeMemory);
return;
}

View File

@ -8,11 +8,5 @@
#include "core/stdafx.h"
#include "tier0/fasttimer.h"
uint64 g_ClockSpeed; // Clocks/sec
unsigned long g_dwClockSpeed;
double g_ClockSpeedMicrosecondsMultiplier;
double g_ClockSpeedMillisecondsMultiplier;
double g_ClockSpeedSecondsMultiplier;
// Constructor init the clock speed.
CClockSpeedInit g_ClockSpeedInit;
CClockSpeed* g_pClockSpeed = new CClockSpeed();

View File

@ -10,37 +10,38 @@
#include "tier0/platform.h"
#include "tier0/cpu.h"
/******************************************************************************/
extern uint64_t g_ClockSpeed;
extern unsigned long g_dwClockSpeed;
extern double g_ClockSpeedMicrosecondsMultiplier;
extern double g_ClockSpeedMillisecondsMultiplier;
extern double g_ClockSpeedSecondsMultiplier;
// -------------------------------------------------------------------------- //
// CClockSpeedInit
// -------------------------------------------------------------------------- //
class CClockSpeedInit
class CClockSpeed
{
public:
CClockSpeedInit(void)
CClockSpeed(void)
{
Init();
}
static void Init(void)
void Init(void)
{
const CPUInformation& pi = GetCPUInformation();
g_ClockSpeed = pi.m_Speed;
g_dwClockSpeed = (unsigned long)g_ClockSpeed;
m_nClockSpeed = pi.m_Speed;
m_dwClockSpeed = (unsigned long)m_nClockSpeed;
g_ClockSpeedMicrosecondsMultiplier = 1000000.0 / (double)g_ClockSpeed;
g_ClockSpeedMillisecondsMultiplier = 1000.0 / (double)g_ClockSpeed;
g_ClockSpeedSecondsMultiplier = 1.0f / (double)g_ClockSpeed;
m_dClockSpeedMicrosecondsMultiplier = 1000000.0 / (double)m_nClockSpeed;
m_dClockSpeedMillisecondsMultiplier = 1000.0 / (double)m_nClockSpeed;
m_dClockSpeedSecondsMultiplier = 1.0f / (double)m_nClockSpeed;
}
uint64_t m_nClockSpeed;
uint32_t m_dwClockSpeed;
double m_dClockSpeedMicrosecondsMultiplier;
double m_dClockSpeedMillisecondsMultiplier;
double m_dClockSpeedSecondsMultiplier;
};
extern CClockSpeed* g_pClockSpeed;
/******************************************************************************/
@ -234,8 +235,8 @@ inline void CCycleCount::Init(void)
inline void CCycleCount::Init(float initTimeMsec)
{
if (g_ClockSpeedMillisecondsMultiplier > 0)
Init((uint64_t)(initTimeMsec / g_ClockSpeedMillisecondsMultiplier));
if (g_pClockSpeed->m_dClockSpeedMillisecondsMultiplier > 0)
Init((uint64_t)(initTimeMsec / g_pClockSpeed->m_dClockSpeedMillisecondsMultiplier));
else
Init((uint64_t)0);
}
@ -290,37 +291,37 @@ inline uint64_t CCycleCount::GetLongCycles(void) const
inline unsigned long CCycleCount::GetMicroseconds(void) const
{
return (unsigned long)((m_Int64 * 1000000) / g_ClockSpeed);
return (unsigned long)((m_Int64 * 1000000) / g_pClockSpeed->m_nClockSpeed);
}
inline uint64_t CCycleCount::GetUlMicroseconds(void) const
{
return ((m_Int64 * 1000000) / g_ClockSpeed);
return ((m_Int64 * 1000000) / g_pClockSpeed->m_nClockSpeed);
}
inline double CCycleCount::GetMicrosecondsF(void) const
{
return (double)(m_Int64 * g_ClockSpeedMicrosecondsMultiplier);
return (double)(m_Int64 * g_pClockSpeed->m_dClockSpeedMicrosecondsMultiplier);
}
inline void CCycleCount::SetMicroseconds(unsigned long nMicroseconds)
{
m_Int64 = ((uint64_t)nMicroseconds * g_ClockSpeed) / 1000000;
m_Int64 = ((uint64_t)nMicroseconds * g_pClockSpeed->m_nClockSpeed) / 1000000;
}
inline unsigned long CCycleCount::GetMilliseconds(void) const
{
return (unsigned long)((m_Int64 * 1000) / g_ClockSpeed);
return (unsigned long)((m_Int64 * 1000) / g_pClockSpeed->m_nClockSpeed);
}
inline double CCycleCount::GetMillisecondsF(void) const
{
return (double)(m_Int64 * g_ClockSpeedMillisecondsMultiplier);
return (double)(m_Int64 * g_pClockSpeed->m_dClockSpeedMillisecondsMultiplier);
}
inline double CCycleCount::GetSeconds(void) const
{
return (double)(m_Int64 * g_ClockSpeedSecondsMultiplier);
return (double)(m_Int64 * g_pClockSpeed->m_dClockSpeedSecondsMultiplier);
}
// -------------------------------------------------------------------------- //
@ -361,7 +362,7 @@ inline CCycleCount CFastTimer::GetDurationInProgress(void) const
inline unsigned long CFastTimer::GetClockSpeed(void)
{
return g_dwClockSpeed;
return g_pClockSpeed->m_dwClockSpeed;
}
inline CCycleCount const& CFastTimer::GetDuration(void) const
@ -489,7 +490,7 @@ inline CAverageTimeMarker::~CAverageTimeMarker(void)
//-----------------------------------------------------------------------------
inline void CLimitTimer::SetLimit(uint64_t cMicroSecDuration)
{
uint64_t dlCycles = ((uint64_t)cMicroSecDuration * (uint64_t)g_dwClockSpeed) / (uint64_t)1000000L;
uint64_t dlCycles = ((uint64_t)cMicroSecDuration * (uint64_t)g_pClockSpeed->m_dwClockSpeed) / (uint64_t)1000000L;
CCycleCount cycleCount;
cycleCount.Sample();
m_lCycleLimit = cycleCount.GetLongCycles() + dlCycles;
@ -519,7 +520,7 @@ inline int CLimitTimer::CMicroSecOverage(void) const
if (lcCycles < m_lCycleLimit)
return 0;
return((int)((lcCycles - m_lCycleLimit) * (uint64_t)1000000L / g_dwClockSpeed));
return((int)((lcCycles - m_lCycleLimit) * (uint64_t)1000000L / g_pClockSpeed->m_dwClockSpeed));
}
//-----------------------------------------------------------------------------
@ -535,7 +536,7 @@ inline uint64_t CLimitTimer::CMicroSecLeft(void) const
if (lcCycles >= m_lCycleLimit)
return 0;
return((uint64_t)((m_lCycleLimit - lcCycles) * (uint64_t)1000000L / g_dwClockSpeed));
return((uint64_t)((m_lCycleLimit - lcCycles) * (uint64_t)1000000L / g_pClockSpeed->m_dwClockSpeed));
}
// -------------------------------------------------------------------------- //