diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 8c760ac35..8bf9d9b7f 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -902,10 +902,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string checkRawTokens(tokenizer); // Simplify tokens into normal form, skip rest of iteration if failed - Timer timer2("Tokenizer::simplifyTokens1", mSettings.showtime, &s_timerResults); - const bool result = tokenizer.simplifyTokens1(mCurrentConfig); - timer2.stop(); - if (!result) + if (!tokenizer.simplifyTokens1(mCurrentConfig)) continue; // dump xml if --dump diff --git a/lib/timer.cpp b/lib/timer.cpp index d1d655ac8..06571b257 100644 --- a/lib/timer.cpp +++ b/lib/timer.cpp @@ -58,7 +58,17 @@ void TimerResults::showResults(SHOWTIME_MODES mode) const for (std::vector::const_iterator iter=data.cbegin(); iter!=data.cend(); ++iter) { const double sec = iter->second.seconds(); const double secAverage = sec / (double)(iter->second.mNumberOfResults); - overallData.mClocks += iter->second.mClocks; + bool hasParent = false; + { + // Do not use inner timers in "Overall time" + const std::string::size_type pos = iter->first.rfind("::"); + if (pos != std::string::npos) + hasParent = std::any_of(data.cbegin(), data.cend(), [iter,pos](const dataElementType& d) { + return d.first.size() == pos && iter->first.compare(0, d.first.size(), d.first) == 0; + }); + } + if (!hasParent) + overallData.mClocks += iter->second.mClocks; if ((mode != SHOWTIME_MODES::SHOWTIME_TOP5) || (ordinal<=5)) { std::cout << iter->first << ": " << sec << "s (avg. " << secAverage << "s - " << iter->second.mNumberOfResults << " result(s))" << std::endl; } diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 47ad27ce3..dc981432a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3251,8 +3251,14 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration) mConfiguration = configuration; - if (!simplifyTokenList1(list.getFiles().front().c_str())) - return false; + if (mTimerResults) { + Timer t("Tokenizer::simplifyTokens1::simplifyTokenList1", mSettings->showtime, mTimerResults); + if (!simplifyTokenList1(list.getFiles().front().c_str())) + return false; + } else { + if (!simplifyTokenList1(list.getFiles().front().c_str())) + return false; + } if (mTimerResults) { Timer t("Tokenizer::simplifyTokens1::createAst", mSettings->showtime, mTimerResults); @@ -5298,7 +5304,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // Bail out if code is garbage if (mTimerResults) { - Timer t("Tokenizer::tokenize::findGarbageCode", mSettings->showtime, mTimerResults); + Timer t("Tokenizer::simplifyTokens1::simplifyTokenList1::findGarbageCode", mSettings->showtime, mTimerResults); findGarbageCode(); } else { findGarbageCode(); @@ -5469,7 +5475,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // typedef.. if (mTimerResults) { - Timer t("Tokenizer::tokenize::simplifyTypedef", mSettings->showtime, mTimerResults); + Timer t("Tokenizer::simplifyTokens1::simplifyTokenList1::simplifyTypedef", mSettings->showtime, mTimerResults); simplifyTypedef(); } else { simplifyTypedef(); @@ -5577,7 +5583,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) if (!isC()) { // Handle templates.. if (mTimerResults) { - Timer t("Tokenizer::tokenize::simplifyTemplates", mSettings->showtime, mTimerResults); + Timer t("Tokenizer::simplifyTokens1::simplifyTokenList1::simplifyTemplates", mSettings->showtime, mTimerResults); simplifyTemplates(); } else { simplifyTemplates(); @@ -5607,7 +5613,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) validate(); // #6772 "segmentation fault (invalid code) in Tokenizer::setVarId" if (mTimerResults) { - Timer t("Tokenizer::tokenize::setVarId", mSettings->showtime, mTimerResults); + Timer t("Tokenizer::simplifyTokens1::simplifyTokenList1::setVarId", mSettings->showtime, mTimerResults); setVarId(); } else { setVarId();