void Timer::calcLatency() { minMicroSecondsLatency = 0; normMicroSecondsLatency = 0; if (!available) return; double minimumAccumulation = 0; int minimumAccumulations = 0; double normalAccumulation = 0; int normalAccumulations = 0; for (int i = 10; i > 0; i--) { LARGE_INTEGER tick1; LARGE_INTEGER tick2; QueryPerformanceCounter(&tick1); QueryPerformanceCounter(&tick2); double begin = tick1.QuadPart * (1000000.0 / frequency.QuadPart); double end = tick2.QuadPart * (1000000.0 / frequency.QuadPart); minimumAccumulation += end - begin; minimumAccumulations++; start(); normalAccumulation += getMicroSeconds(); normalAccumulations++; } if (minimumAccumulations > 0) minMicroSecondsLatency = minimumAccumulation / minimumAccumulations; if (normalAccumulations > 0) normMicroSecondsLatency = normalAccumulation / normalAccumulations; }
std::string CCopasiTimeVariable::isoFormat() const { std::stringstream Iso; bool first = true; if (mTime < LLONG_CONST(0)) { CCopasiTimeVariable Tmp(-mTime); Iso << "-"; Iso << Tmp.isoFormat(); return Iso.str(); } if (mTime >= LLONG_CONST(86400000000)) { Iso << LL2String(getDays()) << ":"; first = false; } if (mTime >= LLONG_CONST(3600000000)) Iso << LL2String(getHours(true), first ? 0 : 2) << ":"; if (mTime >= LLONG_CONST(60000000)) Iso << LL2String(getMinutes(true), first ? 0 : 2) << ":"; if (mTime >= LLONG_CONST(1000000)) Iso << LL2String(getSeconds(true), first ? 0 : 2) << "."; else Iso << "0."; Iso << LL2String(getMilliSeconds(true), 3) << LL2String(getMicroSeconds(true), 3); return Iso.str(); }
inline Profiler::Slot Profiler::beginSection( const char* name, GPUInterface* gpuif ) { GLuint queryFrame = m_numFrames % FRAME_DELAY; Slot slot = m_frameEntries++; if (slot >= m_entries.size()){ grow((unsigned int)(m_entries.size() * 2)); if (gpuif){ gpuif->TimerGrow( getRequiredTimers() ); } } if (m_entries[slot].name != name || m_entries[slot].gpuif != gpuif ) { m_entries[slot].name = name; m_entries[slot].gpuif = gpuif; m_resetDelay = CONFIG_DELAY; } int level = m_level++; m_entries[slot].level = level; m_entries[slot].splitter = false; #ifdef SUPPORT_NVTOOLSEXT { nvtxEventAttributes_t eventAttrib = {0}; eventAttrib.version = NVTX_VERSION; eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; eventAttrib.colorType = NVTX_COLOR_ARGB; unsigned char color[4]; color[0] = 255; color[1] = 0; color[2] = slot % 2 ? 127 : 255; color[3] = 255; color[2] -= level * 16; color[3] -= level * 16; eventAttrib.color = *(uint32_t*)(color); eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; eventAttrib.message.ascii = name; nvtxRangePushEx(&eventAttrib); } #endif if (gpuif){ gpuif->TimerSetup( getTimerIdx(slot,queryFrame,true) ); } else{ glQueryCounter(m_entries[slot].queries[queryFrame],GL_TIMESTAMP); } m_entries[slot].deltas[queryFrame] = -getMicroSeconds(); return slot; }
/** * @brief Initialization function for each subsystem; */ void initialize(int argc, char **argv) { // Reference Time program_start_time_us = getMicroSeconds(); // get the reference time in u_sec (microseconds) when system program_start_time_ms = program_start_time_us/1000; // get the reference time in m_sec (milliseconds) when system // Initialize Different Subsytems initComsys(); initVisionsys(argc, argv); initUisys(); g_system_status.navigation_mode = NAV_MODE_SEMIAUTO; }
static unsigned long defaultSeed() { int64_t seed = Config::getValue(Config::RANDOM_SEED).convert<int>(); if (seed < 0) { // system time in mirsoseconds since 1970 seed = getMicroSeconds(); } unsigned long maxl = std::numeric_limits<unsigned long>::max() - 2; seed = seed % maxl; return (unsigned long)seed; }
inline void Profiler::endSection( Slot slot ) { GLuint queryFrame = m_numFrames % FRAME_DELAY; m_entries[slot].deltas[queryFrame] += getMicroSeconds(); if (m_entries[slot].gpuif){ m_entries[slot].gpuif->TimerSetup( getTimerIdx(slot,queryFrame,false) ); } else{ glQueryCounter(m_entries[slot].queries[queryFrame + FRAME_DELAY],GL_TIMESTAMP); #if NV_TIMER_FLUSH glFlush(); #endif } #ifdef SUPPORT_NVTOOLSEXT nvtxRangePop(); #endif m_level--; }
void Timer::report() const { int64_t ms = getMicroSeconds(); int seconds = ms / 1000000; PRINT_MSG("%s took %d'%02d\" (%" PRId64 " us) %s", m_name.c_str(), seconds / 60, seconds % 60, ms, getName()); }
MilliSeconds GetMilliSeconds(void) { return (MilliSeconds) (getMicroSeconds() / 1000ULL); }
double Timer::getMilliSeconds() { return (getMicroSeconds() * 0.001); }