Add random functions and align log

This commit is contained in:
grayson committed 2025-01-30 13:29:01 -06:00
1 parent a31c7ab55b
commit 986719a405
4 files changed
+18 -6

No files matched your search

+2 -5
View File
@@ -16,11 +16,8 @@ namespace nf {
SetThreadDescription(GetCurrentThread(), L"NF Main Thread");
SetConsoleTitle(std::format("{} Debug Console - {}", engineStr, gameStr).c_str());
#endif
{
NFTime();
std::this_thread::sleep_for(std::chrono::seconds(1));
NFLog("Test!");
}
for (int i = 0; i < 10; i++)
NFLog(util::getRandRange(3, 5));
std::cin.get();
}
+4
View File
@@ -3,6 +3,7 @@
#include "util/log.h"
// Define NFTime
#ifdef _DEBUG
#define NFTime() ::nf::util::ScopedTimer __scopeTimer(__FUNCSIG__)
#else
@@ -10,6 +11,9 @@
#endif
namespace nf::util {
double getRand();
double getRandRange(double minimum, double maximum);
class ScopedTimer {
public:
ScopedTimer(const char* funcName);
+1 -1
View File
@@ -37,7 +37,7 @@ namespace nf::util {
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) {
+11
View File
@@ -3,7 +3,18 @@
#include "util.h"
#undef max
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)
: m_funcName(funcName)
, m_startTime(std::chrono::high_resolution_clock::now())