本文整理汇总了C++中PerformanceTimer类的典型用法代码示例。如果您正苦于以下问题:C++ PerformanceTimer类的具体用法?C++ PerformanceTimer怎么用?C++ PerformanceTimer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PerformanceTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void TaskQueue::update(float maxTime)
{
PerformanceTimer timer;
timer.start();
TaskRequest *req;
resultQLock.enter();
while (!resultQ.empty() && (maxTime==0 || timer.getSplitTime() < maxTime))
{
req=resultQ.back();
resultQ.pop_back();
--numResults;
--sm_iTotalNumResults;
resultQLock.leave();
if (req->mainThreadFinish())
{
req->mainThreadOnComplete();
delete req;
}
else
{
// if Finish() returns false, more worker thread processing is needed
asyncRequest(req);
}
resultQLock.enter();
}
resultQLock.leave();
}
示例2: draw
void GLVSyncTestRenderer::draw(QPainter* painter, QPaintEvent* /*event*/) {
PerformanceTimer timer;
//int t5, t6, t7, t8, t9, t10, t11, t12, t13;
timer.start();
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return;
}
ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
return;
}
const int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return;
}
const WaveformData* data = waveform->data();
if (data == NULL) {
return;
}
double firstVisualIndex = m_waveformRenderer->getFirstDisplayedPosition() * dataSize;
double lastVisualIndex = m_waveformRenderer->getLastDisplayedPosition() * dataSize;
const int firstIndex = int(firstVisualIndex + 0.5);
firstVisualIndex = firstIndex - firstIndex % 2;
const int lastIndex = int(lastVisualIndex + 0.5);
lastVisualIndex = lastIndex + lastIndex % 2;
//t5 = timer.restart(); // 910
// Reset device for native painting
painter->beginNativePainting();
//t6 = timer.restart(); // 29,150
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Removed Unsupported OpenGL functions, so that Mixxx can run on OpenGL-ES systems -- amvanbaren 9/2015
// TODO(XXX) Rewrite OpenGL code in glvsynctestrenderer.cpp to support
// the new OpenGL syntax or use Qt instead
//t12 = timer.restart(); // 22,426
painter->endNativePainting();
//t13 = timer.restart(); // 1,430
//qDebug() << t5 << t6 << t7 << t8 << t9 << t10 << t11 << t12 << t13;
//qDebug() << timer.restart(); // 129,498
}
示例3: update
void ServerPathBuildManager::update ( float timeBudget )
{
PerformanceTimer timer;
timer.start();
updateQueue( &gs_highQueue, timer, timeBudget );
updateQueue( &gs_lowQueue, timer, timeBudget );
}
示例4: setupAssertionHandler
bool TestManager::runTestsWithFilter(const std::string & incl, const std::string & excl)
{
// Keep current assertion handler and setup ours
setupAssertionHandler();
setupLogCapturingHandler();
// Prepare tags for filtering
auto included_tags = detail::SplitString(incl, ' ');
auto excluded_tags = detail::SplitString(excl, ' ');
_test_log.clearLogData();
logHeader("== " + _test_manager_name + " Unit Tests Log");
if (included_tags.size() > 0 || excluded_tags.size() > 0) {
if (included_tags.size()) {
logMessage(detail::FormattedString(" * included tags : %s", incl.c_str()));
}
if (excluded_tags.size()) {
logMessage(detail::FormattedString(" * excluded tags : %s", excl.c_str()));
}
logSeparator();
}
bool tests_result = true;
double elapsed_time = 0.0;
if (_registered_tests.size() > 0) {
//
PerformanceTimer timer;
tests_result = executeFilteredTests(included_tags, excluded_tags);
elapsed_time = timer.elapsedTime();
//
} else {
//
logMessage("WARNING: There's no registered test!");
//
}
// Keep elapsed time & report results to log
tl().setElapsedTime(elapsed_time);
TestLogData::Counters log_data_counters = tl().logDataCounters();
logHeader(detail::FormattedString("== RESULTS: %d passed, %d failed, %d skipped, time %s",
log_data_counters.passed_tests,
log_data_counters.failed_tests,
log_data_counters.skipped_tests,
PerformanceTimer::humanReadableTime(elapsed_time).c_str()));
// Set previous assertion handler back
restoreLogCapturingHandler();
restoreAssertionHandler();
return tests_result;
}
示例5: CloseHandle
OsFile::~OsFile()
{
#ifdef _DEBUG
PerformanceTimer t;
t.start();
#endif
CloseHandle(m_handle);
#ifdef _DEBUG
t.stop();
ms_time+= t.getElapsedTime();
#endif
}
示例6: render
mixxx::Duration GLRGBWaveformWidget::render() {
PerformanceTimer timer;
mixxx::Duration t1;
//mixxx::Duration t2, t3;
timer.start();
// QPainter makes QGLContext::currentContext() == context()
// this may delayed until previous buffer swap finished
QPainter painter(this);
t1 = timer.restart();
draw(&painter, NULL);
//t2 = timer.restart();
//qDebug() << "GLRGBWaveformWidget" << t1 << t2;
return t1; // return timer for painter setup
}
示例7: s_pfpgGetSystemTimeFn
// static
qint64 EngineNetworkStream::getNetworkTimeUs() {
// This matches the GPL2 implementation found in
// https://github.com/codders/libshout/blob/a17fb84671d3732317b0353d7281cc47e2df6cf6/src/timing/timing.c
// Instead of ms resolution we use a us resolution to allow low latency settings
// will overflow > 200,000 years
#ifdef __WINDOWS__
FILETIME ft;
qint64 t;
// no GetSystemTimePreciseAsFileTime available, fall
// back to GetSystemTimeAsFileTime. This happens before
// Windows 8 and Windows Server 2012
// GetSystemTime?AsFileTime is NTP adjusted
// QueryPerformanceCounter depends on the CPU crystal
if(s_pfpgGetSystemTimeFn) {
s_pfpgGetSystemTimeFn(&ft);
return ((qint64)ft.dwHighDateTime << 32 | ft.dwLowDateTime) / 10;
} else {
static qint64 oldNow = 0;
static qint64 incCount = 0;
static PerformanceTimer timerSinceInc;
GetSystemTimeAsFileTime(&ft);
qint64 now = ((qint64)ft.dwHighDateTime << 32 | ft.dwLowDateTime) / 10;
if (now == oldNow) {
// timer was not incremented since last call (< 15 ms)
// Add time since last function call after last increment
// This reduces the jitter < one call cycle which is sufficient
LARGE_INTEGER li;
now += timerSinceInc.elapsed().toIntegerMicros();
} else {
// timer was incremented
LARGE_INTEGER li;
timerSinceInc.start();
oldNow = now;
}
return now;
}
#elif defined(__APPLE__)
// clock_gettime is not implemented on OSX
// gettimeofday can go backward due to NTP adjusting
// this will work here, because we take the stream start time for reference
struct timeval mtv;
gettimeofday(&mtv, NULL);
return (qint64)(mtv.tv_sec) * 1000000 + mtv.tv_usec;
#else
// CLOCK_MONOTONIC is NTP adjusted
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000000LL + ts.tv_nsec / 1000;
#endif
}
示例8: test_factory
bool TestManager::executeTest(UnitTestCreationInfo ti, const std::string & full_test_desc)
{
bool test_result = false;
detail::UnitTestFactoryFunction test_factory = ti->factory;
UnitTest * unit_test = test_factory ? test_factory() : nullptr;
if (unit_test != nullptr) {
std::string begin_message = full_test_desc + " ::: START";
logMessage(begin_message);
// Set indentation and run test
tl().setIndentationLevel(2);
PerformanceTimer timer;
double elapsed_time = 0.0;
try {
test_result = unit_test->runTest(this, &_test_log);
elapsed_time = timer.elapsedTime();
} catch (std::exception & exc) {
std::string message("FAILED: Exception: ");
message.append(exc.what());
logMessage(message);
test_result = false;
} catch (...) {
logMessage(std::string("FAILED: An unknown exception occured."));
test_result = false;
}
// Clear indentation & dump result
tl().setIndentationLevel(0);
std::string end_message = full_test_desc;
if (test_result) {
end_message += " ::: OK ::: " + PerformanceTimer::humanReadableTime(elapsed_time);
} else {
end_message += " ::: FAILED";
}
logMessage(end_message);
logSeparator();
// destroy unit test object
delete unit_test;
} else {
CC7_ASSERT(false, "Unable to create '%s'", full_test_desc.c_str());
}
return test_result;
}
示例9: render
int GLRGBWaveformWidget::render() {
PerformanceTimer timer;
int t1;
//int t2, t3;
timer.start();
// QPainter makes QGLContext::currentContext() == context()
// this may delayed until previous buffer swap finished
QPainter painter(this);
t1 = timer.restart();
draw(&painter, NULL);
//t2 = timer.restart();
// glFinish();
//t3 = timer.restart();
//qDebug() << "GLVSyncTestWidget "<< t1 << t2 << t3;
return t1 / 1000; // return timer for painter setup
}
示例10: GetTicksNanos
// Delegate to PerformanceTimer.
uint64_t Timer::GetTicksNanos()
{
if (useFakeSeconds)
return (uint64_t) (FakeSeconds * NanosPerSecond);
return Win32_PerfTimer.GetTimeNanos();
}
示例11:
/**
* Starts the launch2FocusLock trace.
*/
void Launch2FocusLock::start(void)
{
if (gLaunch2FocusLock.isRequested()) {
gLaunch2FocusLock.formattedTrace("Launch2FocusLock", __FUNCTION__);
gLaunch2FocusLock.start();
}
}
示例12: stop
/**
* Stop the performance tracer.
*/
void PnPBreakdown::stop(void)
{
if (gPnPBreakdown.isRunning()) {
gPnPBreakdown.formattedTrace("PnPBreakdown", __FUNCTION__);
gPnPBreakdown.stop();
}
}
示例13: start
/**
* Start the log breakdown performance tracer.
*/
void PnPBreakdown::start(void)
{
if (gPnPBreakdown.isRequested()) {
gPnPBreakdown.formattedTrace("PnPBreakdown", __FUNCTION__);
gPnPBreakdown.start();
}
}
示例14: LOGD
IOBreakdown::~IOBreakdown()
{
char memData[MEM_DATA_LEN]={0};
if (!mNote)
mNote = "";
if (mMemInfoEnabled) {
mMemMutex.lock();
if (mDbgFD < 0) {
LOGD("dgbopt isn't opened.");
} else {
::write(mDbgFD, DBG_CTRL, 3);
if (mPipeFD < 0) {
LOGD("trace_pipe isn't opened.");
} else {
int n;
do {
n = ::read(mPipeFD, memData, MEM_DATA_LEN - 1);
}while (n<=0);
LOGD("memory <%s,%d>:%s", mNote, n, memData);
}
}
mMemMutex.unlock();
}
LOGD("IOBreakdown-step %s:%s, Time: %lld us, Diff: %lld us",
mFuncName, mNote, gIOBreakdown.timeUs(), gIOBreakdown.lastTimeUs());
}
示例15: mFuncName
/**
* To indicate the performance and memory for every IOCTL call.
*
* @arg func, the function name which called it.
* @arg note, a string printed with IOCTL information.
*/
IOBreakdown::IOBreakdown(const char *func, const char *note):
mFuncName(func)
,mNote(note)
{
if (gIOBreakdown.isRunning()) {
gIOBreakdown.timeUs();
gIOBreakdown.lastTimeUs();
}
}