Add random functions and align log
This commit is contained in:
parent
a31c7ab55b
commit
986719a405
@ -16,11 +16,8 @@ namespace nf {
|
|||||||
SetThreadDescription(GetCurrentThread(), L"NF Main Thread");
|
SetThreadDescription(GetCurrentThread(), L"NF Main Thread");
|
||||||
SetConsoleTitle(std::format("{} Debug Console - {}", engineStr, gameStr).c_str());
|
SetConsoleTitle(std::format("{} Debug Console - {}", engineStr, gameStr).c_str());
|
||||||
#endif
|
#endif
|
||||||
{
|
for (int i = 0; i < 10; i++)
|
||||||
NFTime();
|
NFLog(util::getRandRange(3, 5));
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
||||||
NFLog("Test!");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cin.get();
|
std::cin.get();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
|
// Define NFTime
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define NFTime() ::nf::util::ScopedTimer __scopeTimer(__FUNCSIG__)
|
#define NFTime() ::nf::util::ScopedTimer __scopeTimer(__FUNCSIG__)
|
||||||
#else
|
#else
|
||||||
@ -10,6 +11,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace nf::util {
|
namespace nf::util {
|
||||||
|
double getRand();
|
||||||
|
double getRandRange(double minimum, double maximum);
|
||||||
|
|
||||||
class ScopedTimer {
|
class ScopedTimer {
|
||||||
public:
|
public:
|
||||||
ScopedTimer(const char* funcName);
|
ScopedTimer(const char* funcName);
|
||||||
|
@ -37,7 +37,7 @@ namespace nf::util {
|
|||||||
|
|
||||||
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - s_initTime);
|
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - s_initTime);
|
||||||
|
|
||||||
std::cout << std::format("[{:9.3f}] NF {}: {}\n", time.count() * 1e-3, s_logTypesMap[type], msg);
|
std::cout << std::format("[{:9.3f}][NF {}]:\t{}\n", time.count() * 1e-3, s_logTypesMap[type], msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(const std::string& msg, LogType type) {
|
void log(const std::string& msg, LogType type) {
|
||||||
|
@ -3,7 +3,18 @@
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#undef max
|
||||||
|
|
||||||
namespace nf::util {
|
namespace nf::util {
|
||||||
|
double getRand() {
|
||||||
|
static std::random_device dev;
|
||||||
|
return static_cast<double>(dev()) / dev.max();
|
||||||
|
}
|
||||||
|
|
||||||
|
double getRandRange(double minimum, double maximum) {
|
||||||
|
return getRand() * (maximum - minimum) + minimum;
|
||||||
|
}
|
||||||
|
|
||||||
ScopedTimer::ScopedTimer(const char* funcName)
|
ScopedTimer::ScopedTimer(const char* funcName)
|
||||||
: m_funcName(funcName)
|
: m_funcName(funcName)
|
||||||
, m_startTime(std::chrono::high_resolution_clock::now())
|
, m_startTime(std::chrono::high_resolution_clock::now())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user