mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
loader: wrap elapsed time in Timer::GetTime (#679)
loader: format elapsed log timestamps beyond 24 hours Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
+1
-10
@@ -38,16 +38,7 @@ bool Timer::IsPaused() const {
|
||||
|
||||
// return time in milliseconds
|
||||
double Timer::GetTimeMs() const {
|
||||
if (m_is_paused) {
|
||||
return 1000.0 * (static_cast<double>(m_PauseTime - m_StartTime)) /
|
||||
static_cast<double>(m_Frequency);
|
||||
}
|
||||
|
||||
uint64_t current_time = 0;
|
||||
SysQueryPerformanceCounter(¤t_time);
|
||||
|
||||
return 1000.0 * (static_cast<double>(current_time - m_StartTime)) /
|
||||
static_cast<double>(m_Frequency);
|
||||
return GetTimeS() * 1000.0;
|
||||
}
|
||||
|
||||
// return time in seconds
|
||||
|
||||
+6
-1
@@ -7,6 +7,8 @@
|
||||
#include "common/threads.h"
|
||||
#include "loader/timer.h" // IWYU pragma: keep
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define PRINT_NAME_ENABLED g_print_name
|
||||
|
||||
@@ -50,7 +52,10 @@
|
||||
#define PRINT_NAME() \
|
||||
if (PRINT_NAME_ENABLED) { \
|
||||
if (Log::GetDirection() != Log::Direction::Silent) { \
|
||||
const auto print_name_time = Loader::Timer::GetTime().ToString("HH24:MI:SS.FFF"); \
|
||||
const auto elapsed_ms = static_cast<uint64_t>(Loader::Timer::GetTimeMs()); \
|
||||
const auto print_name_time = fmt::format( \
|
||||
"{:02}:{:02}:{:02}.{:03}", elapsed_ms / 3600000, (elapsed_ms / 60000) % 60, \
|
||||
(elapsed_ms / 1000) % 60, elapsed_ms % 1000); \
|
||||
LOGF_COLOR(Log::Color::Cyan, "[%d][%s] %s::%s::%s()\n", \
|
||||
Common::Thread::GetThreadIdUnique(), print_name_time.c_str(), g_library, \
|
||||
g_module, __func__); \
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "common/timer.h"
|
||||
|
||||
#include "common/abi.h"
|
||||
#include "common/dateTime.h"
|
||||
#include "loader/timer.h"
|
||||
|
||||
namespace Loader::Timer {
|
||||
@@ -16,8 +14,4 @@ double GetTimeMs() {
|
||||
return g_timer.GetTimeMs();
|
||||
}
|
||||
|
||||
Common::Time GetTime() {
|
||||
return Common::Time(static_cast<int>(GetTimeMs()));
|
||||
}
|
||||
|
||||
} // namespace Loader::Timer
|
||||
|
||||
+2
-6
@@ -1,14 +1,10 @@
|
||||
#ifndef EMULATOR_INCLUDE_EMULATOR_LOADER_TIMER_H_
|
||||
#define EMULATOR_INCLUDE_EMULATOR_LOADER_TIMER_H_
|
||||
|
||||
#include "common/abi.h"
|
||||
#include "common/common.h"
|
||||
#include "common/dateTime.h"
|
||||
namespace Loader::Timer {
|
||||
|
||||
void Start();
|
||||
double GetTimeMs();
|
||||
Common::Time GetTime();
|
||||
void Start();
|
||||
double GetTimeMs();
|
||||
|
||||
struct Lifecycle {
|
||||
static constexpr const char* name = "Timer";
|
||||
|
||||
@@ -27,8 +27,8 @@ bool SystemContentParamSfoGetString(const char*, std::string* value) {
|
||||
}
|
||||
void SymbolDatabase::Add(const SymbolResolve&, uint64_t, const std::string&) {}
|
||||
namespace Timer {
|
||||
Common::Time GetTime() {
|
||||
return Common::Time(0);
|
||||
double GetTimeMs() {
|
||||
return 0.0;
|
||||
}
|
||||
} // namespace Timer
|
||||
} // namespace Loader
|
||||
|
||||
Reference in New Issue
Block a user