diff --git a/include/system.hpp b/include/system.hpp index 3889ff5f..3128be43 100644 --- a/include/system.hpp +++ b/include/system.hpp @@ -132,9 +132,9 @@ void setThreadName(const std::string& name); /** Returns the caller's human-readable stack trace with "\n"-separated lines. */ std::string getStackTrace(); /** Returns the number of seconds since application launch. -The goal of this function is to give the most precise (fine-grained) time differences available on the OS for benchmarking purposes, while being fast to compute. +Gives the most precise (fine-grained) time differences available on the OS for benchmarking purposes, while being fast to compute. */ -double getRuntime(); +double getTime(); /** Returns time since 1970-01-01 00:00:00 UTC in seconds. */ double getUnixTime(); diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 2427b957..22cf3023 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -564,7 +564,7 @@ void Engine::step(int frames) { random::init(); internal->stepFrame = internal->frame; - internal->stepTime = system::getRuntime(); + internal->stepTime = system::getTime(); internal->stepFrames = frames; // Set sample rate @@ -596,7 +596,7 @@ void Engine::step(int frames) { yieldWorkers(); - double endTime = system::getRuntime(); + double endTime = system::getTime(); float duration = endTime - internal->stepTime; float stepDuration = internal->stepFrames * internal->sampleTime; // DEBUG("%d %f / %f = %f%%", internal->stepFrames, duration, stepDuration, duration / stepDuration * 100.f); diff --git a/src/logger.cpp b/src/logger.cpp index 02b684d8..617ac5b3 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -17,7 +17,7 @@ static std::mutex logMutex; void init() { - startTime = system::getRuntime(); + startTime = system::getTime(); // Don't open a file in development mode. if (settings::devMode) { outputFile = stderr; @@ -64,7 +64,7 @@ static void logVa(Level level, const char* filename, int line, const char* func, if (!outputFile) return; - double nowTime = system::getRuntime(); + double nowTime = system::getTime(); double duration = nowTime - startTime; if (outputFile == stderr) std::fprintf(outputFile, "\x1B[%dm", levelColors[level]); diff --git a/src/midi.cpp b/src/midi.cpp index 5068498b..f8e41df1 100644 --- a/src/midi.cpp +++ b/src/midi.cpp @@ -31,7 +31,7 @@ void InputDevice::onMessage(const Message &message) { // Set timestamp to now if unset Message msg = message; if (msg.timestamp == 0.0) - msg.timestamp = system::getRuntime(); + msg.timestamp = system::getTime(); for (Input* input : subscribed) { // We're probably in the MIDI driver's thread, so set the Rack context. diff --git a/src/patch.cpp b/src/patch.cpp index 78748965..41561eca 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -69,10 +69,10 @@ void PatchManager::save(std::string path) { // Take screenshot (disabled because there is currently no way to quickly view them on any OS or website.) // APP->window->screenshot(system::join(asset::autosavePath, "screenshot.png")); - double startTime = system::getRuntime(); + double startTime = system::getTime(); // Set compression level to 1 so that a 500MB/s SSD is almost bottlenecked system::archiveFolder(path, asset::autosavePath, 1); - double endTime = system::getRuntime(); + double endTime = system::getTime(); INFO("Archived patch in %lf seconds", (endTime - startTime)); } @@ -222,9 +222,9 @@ void PatchManager::load(std::string path) { } else { // Extract the .vcv file as a .tar.zst archive. - double startTime = system::getRuntime(); + double startTime = system::getTime(); system::unarchiveToFolder(path, asset::autosavePath); - double endTime = system::getRuntime(); + double endTime = system::getTime(); INFO("Unarchived patch in %lf seconds", (endTime - startTime)); } diff --git a/src/rtmidi.cpp b/src/rtmidi.cpp index c7382178..bbcf6ae2 100644 --- a/src/rtmidi.cpp +++ b/src/rtmidi.cpp @@ -148,7 +148,7 @@ struct RtMidiOutputDevice : midi::OutputDevice { else { // Get earliest message const midi::Message& message = messageQueue.top(); - double duration = message.timestamp - system::getRuntime(); + double duration = message.timestamp - system::getTime(); // If we need to wait, release the lock and wait for the timeout, or if the CV is notified. // This correctly handles MIDI messages with no timestamp, because duration will be NAN. diff --git a/src/system.cpp b/src/system.cpp index bb390bc4..08ca5003 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -564,7 +564,7 @@ static void initRuntime() { #endif } -double getRuntime() { +double getTime() { #if defined ARCH_WIN LARGE_INTEGER counter; QueryPerformanceCounter(&counter); diff --git a/standalone/main.cpp b/standalone/main.cpp index 2435d659..f2e45ae3 100644 --- a/standalone/main.cpp +++ b/standalone/main.cpp @@ -112,6 +112,7 @@ int main(int argc, char* argv[]) { asset::init(); bool loggerWasTruncated = logger::isTruncated(); logger::init(); + random::init(); // We can now install a signal handler and log the output if (!settings::devMode) { @@ -160,7 +161,6 @@ int main(int argc, char* argv[]) { } INFO("Initializing environment"); - random::init(); network::init(); audio::init(); rtaudioInit();