本文整理汇总了C++中PerformanceTimer::elapsedTime方法的典型用法代码示例。如果您正苦于以下问题:C++ PerformanceTimer::elapsedTime方法的具体用法?C++ PerformanceTimer::elapsedTime怎么用?C++ PerformanceTimer::elapsedTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerformanceTimer
的用法示例。
在下文中一共展示了PerformanceTimer::elapsedTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTestsWithFilter
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;
}
示例2: update
void update()
{
m_currentTime = m_timer.elapsedTime();
// Calculate Frames per second
static float frames = 0;
++frames;
if ( (m_currentTime - m_lastTime) >= 0.1f )
{
Fps = frames / (m_currentTime - m_lastTime);
m_lastTime = m_currentTime;
frames = 0.0f;
}
}
示例3: executeTest
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;
}
示例4: reset
void reset()
{
m_timer.resetTimer();
m_currentTime = m_lastTime = m_timer.elapsedTime();
}
示例5: currentTimeStamp
float currentTimeStamp()
{
return m_timer.elapsedTime();
}