@@ -132,9 +132,9 @@ void setThreadName(const std::string& name); | |||||
/** Returns the caller's human-readable stack trace with "\n"-separated lines. */ | /** Returns the caller's human-readable stack trace with "\n"-separated lines. */ | ||||
std::string getStackTrace(); | std::string getStackTrace(); | ||||
/** Returns the number of seconds since application launch. | /** 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. | /** Returns time since 1970-01-01 00:00:00 UTC in seconds. | ||||
*/ | */ | ||||
double getUnixTime(); | double getUnixTime(); | ||||
@@ -564,7 +564,7 @@ void Engine::step(int frames) { | |||||
random::init(); | random::init(); | ||||
internal->stepFrame = internal->frame; | internal->stepFrame = internal->frame; | ||||
internal->stepTime = system::getRuntime(); | |||||
internal->stepTime = system::getTime(); | |||||
internal->stepFrames = frames; | internal->stepFrames = frames; | ||||
// Set sample rate | // Set sample rate | ||||
@@ -596,7 +596,7 @@ void Engine::step(int frames) { | |||||
yieldWorkers(); | yieldWorkers(); | ||||
double endTime = system::getRuntime(); | |||||
double endTime = system::getTime(); | |||||
float duration = endTime - internal->stepTime; | float duration = endTime - internal->stepTime; | ||||
float stepDuration = internal->stepFrames * internal->sampleTime; | float stepDuration = internal->stepFrames * internal->sampleTime; | ||||
// DEBUG("%d %f / %f = %f%%", internal->stepFrames, duration, stepDuration, duration / stepDuration * 100.f); | // DEBUG("%d %f / %f = %f%%", internal->stepFrames, duration, stepDuration, duration / stepDuration * 100.f); | ||||
@@ -17,7 +17,7 @@ static std::mutex logMutex; | |||||
void init() { | void init() { | ||||
startTime = system::getRuntime(); | |||||
startTime = system::getTime(); | |||||
// Don't open a file in development mode. | // Don't open a file in development mode. | ||||
if (settings::devMode) { | if (settings::devMode) { | ||||
outputFile = stderr; | outputFile = stderr; | ||||
@@ -64,7 +64,7 @@ static void logVa(Level level, const char* filename, int line, const char* func, | |||||
if (!outputFile) | if (!outputFile) | ||||
return; | return; | ||||
double nowTime = system::getRuntime(); | |||||
double nowTime = system::getTime(); | |||||
double duration = nowTime - startTime; | double duration = nowTime - startTime; | ||||
if (outputFile == stderr) | if (outputFile == stderr) | ||||
std::fprintf(outputFile, "\x1B[%dm", levelColors[level]); | std::fprintf(outputFile, "\x1B[%dm", levelColors[level]); | ||||
@@ -31,7 +31,7 @@ void InputDevice::onMessage(const Message &message) { | |||||
// Set timestamp to now if unset | // Set timestamp to now if unset | ||||
Message msg = message; | Message msg = message; | ||||
if (msg.timestamp == 0.0) | if (msg.timestamp == 0.0) | ||||
msg.timestamp = system::getRuntime(); | |||||
msg.timestamp = system::getTime(); | |||||
for (Input* input : subscribed) { | for (Input* input : subscribed) { | ||||
// We're probably in the MIDI driver's thread, so set the Rack context. | // We're probably in the MIDI driver's thread, so set the Rack context. | ||||
@@ -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.) | // 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")); | // 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 | // Set compression level to 1 so that a 500MB/s SSD is almost bottlenecked | ||||
system::archiveFolder(path, asset::autosavePath, 1); | system::archiveFolder(path, asset::autosavePath, 1); | ||||
double endTime = system::getRuntime(); | |||||
double endTime = system::getTime(); | |||||
INFO("Archived patch in %lf seconds", (endTime - startTime)); | INFO("Archived patch in %lf seconds", (endTime - startTime)); | ||||
} | } | ||||
@@ -222,9 +222,9 @@ void PatchManager::load(std::string path) { | |||||
} | } | ||||
else { | else { | ||||
// Extract the .vcv file as a .tar.zst archive. | // Extract the .vcv file as a .tar.zst archive. | ||||
double startTime = system::getRuntime(); | |||||
double startTime = system::getTime(); | |||||
system::unarchiveToFolder(path, asset::autosavePath); | system::unarchiveToFolder(path, asset::autosavePath); | ||||
double endTime = system::getRuntime(); | |||||
double endTime = system::getTime(); | |||||
INFO("Unarchived patch in %lf seconds", (endTime - startTime)); | INFO("Unarchived patch in %lf seconds", (endTime - startTime)); | ||||
} | } | ||||
@@ -148,7 +148,7 @@ struct RtMidiOutputDevice : midi::OutputDevice { | |||||
else { | else { | ||||
// Get earliest message | // Get earliest message | ||||
const midi::Message& message = messageQueue.top(); | 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. | // 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. | // This correctly handles MIDI messages with no timestamp, because duration will be NAN. | ||||
@@ -564,7 +564,7 @@ static void initRuntime() { | |||||
#endif | #endif | ||||
} | } | ||||
double getRuntime() { | |||||
double getTime() { | |||||
#if defined ARCH_WIN | #if defined ARCH_WIN | ||||
LARGE_INTEGER counter; | LARGE_INTEGER counter; | ||||
QueryPerformanceCounter(&counter); | QueryPerformanceCounter(&counter); | ||||
@@ -112,6 +112,7 @@ int main(int argc, char* argv[]) { | |||||
asset::init(); | asset::init(); | ||||
bool loggerWasTruncated = logger::isTruncated(); | bool loggerWasTruncated = logger::isTruncated(); | ||||
logger::init(); | logger::init(); | ||||
random::init(); | |||||
// We can now install a signal handler and log the output | // We can now install a signal handler and log the output | ||||
if (!settings::devMode) { | if (!settings::devMode) { | ||||
@@ -160,7 +161,6 @@ int main(int argc, char* argv[]) { | |||||
} | } | ||||
INFO("Initializing environment"); | INFO("Initializing environment"); | ||||
random::init(); | |||||
network::init(); | network::init(); | ||||
audio::init(); | audio::init(); | ||||
rtaudioInit(); | rtaudioInit(); | ||||