Skip to content

Commit 18492b0

Browse files
authored
refs #14599 - moved printing of summary timer results out of executors (danmar#8347)
1 parent 6c25934 commit 18492b0

File tree

8 files changed

+6
-92
lines changed

8 files changed

+6
-92
lines changed

cli/cppcheckexecutor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
462462
#endif
463463
}
464464

465+
// TODO: show time *after* the whole program analysis
466+
if (settings.showtime == ShowTime::SUMMARY || settings.showtime == ShowTime::TOP5_SUMMARY)
467+
timerResults.showResults(settings.showtime);
468+
465469
// TODO: is this run again instead of using previously cached results?
466470
returnValue |= cppcheck.analyseWholeProgram(settings.buildDir, mFiles, mFileSettings, stdLogger.getCtuInfo());
467471

cli/processexecutor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ unsigned int ProcessExecutor::check()
450450
}
451451

452452
// TODO: we need to get the timing information from the subprocess
453-
if (mTimerResults && (mSettings.showtime == ShowTime::SUMMARY || mSettings.showtime == ShowTime::TOP5_SUMMARY))
454-
mTimerResults->showResults(mSettings.showtime);
455453

456454
return result;
457455
}

cli/singleexecutor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,10 @@ unsigned int SingleExecutor::check()
6767
reportStatus(c, mFileSettings.size(), c, mFileSettings.size());
6868
}
6969

70+
// TODO: show time after the whole program analysis
7071
// TODO: CppCheckExecutor::check_internal() is also invoking the whole program analysis - is it run twice?
7172
if (mCppcheck.analyseWholeProgram())
7273
result++;
7374

74-
if (mTimerResults && (mSettings.showtime == ShowTime::SUMMARY || mSettings.showtime == ShowTime::TOP5_SUMMARY))
75-
mTimerResults->showResults(mSettings.showtime);
76-
7775
return result;
7876
}

cli/threadexecutor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ unsigned int ThreadExecutor::check()
216216
return v + f.get();
217217
});
218218

219-
if (mTimerResults && (mSettings.showtime == ShowTime::SUMMARY || mSettings.showtime == ShowTime::TOP5_SUMMARY))
220-
mTimerResults->showResults(mSettings.showtime);
221-
222219
return result;
223220
}
224221

lib/timer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void Timer::stop()
109109
if (mStart != TimePoint{}) {
110110
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(Clock::now() - mStart);
111111
if (!mResults) {
112+
// TODO: do not print implicitly
112113
std::lock_guard<std::mutex> l(stdCoutLock);
113114
std::cout << (mType == Type::OVERALL ? "Overall time: " : "Check time: " + mName + ": ") << TimerResultsData::durationToString(diff) << std::endl;
114115
} else {

test/testprocessexecutor.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ class TestProcessExecutorBase : public TestFixture {
138138
TEST_CASE(one_error_less_files);
139139
TEST_CASE(one_error_several_files);
140140
TEST_CASE(showtime_top5_file);
141-
TEST_CASE(showtime_top5_summary);
142141
TEST_CASE(showtime_file);
143-
TEST_CASE(showtime_summary);
144142
TEST_CASE(showtime_file_total);
145143
TEST_CASE(suppress_error_library);
146144
TEST_CASE(unique_errors);
@@ -255,20 +253,6 @@ class TestProcessExecutorBase : public TestFixture {
255253
TODO_ASSERT_EQUALS(static_cast<long long>(5 + 1 + 1) * 2, 0, cppcheck::count_all_of(output_s, '\n'));
256254
}
257255

258-
void showtime_top5_summary() {
259-
REDIRECT;
260-
check(2, 2, 0,
261-
"int main() {}",
262-
dinit(CheckOptions,
263-
$.showtime = ShowTime::TOP5_SUMMARY));
264-
const std::string output_s = GET_REDIRECT_OUTPUT;
265-
// once: top5 results + overall + empty line
266-
TODO_ASSERT_EQUALS(5 + 1 + 1, 1, cppcheck::count_all_of(output_s, '\n'));
267-
// should only report the top5 once
268-
ASSERT(output_s.find("1 result(s)") == std::string::npos);
269-
TODO_ASSERT(output_s.find("2 result(s)") != std::string::npos);
270-
}
271-
272256
void showtime_file() {
273257
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
274258
check(2, 2, 0,
@@ -279,18 +263,6 @@ class TestProcessExecutorBase : public TestFixture {
279263
TODO_ASSERT_EQUALS(2, 0, cppcheck::count_all_of(output_s, "Overall time:"));
280264
}
281265

282-
void showtime_summary() {
283-
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
284-
check(2, 2, 0,
285-
"int main() {}",
286-
dinit(CheckOptions,
287-
$.showtime = ShowTime::SUMMARY));
288-
const std::string output_s = GET_REDIRECT_OUTPUT;
289-
// should only report the actual summary once
290-
ASSERT(output_s.find("1 result(s)") == std::string::npos);
291-
TODO_ASSERT(output_s.find("2 result(s)") != std::string::npos);
292-
}
293-
294266
void showtime_file_total() {
295267
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
296268
check(2, 2, 0,

test/testsingleexecutor.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ class TestSingleExecutorBase : public TestFixture {
128128
TEST_CASE(one_error_less_files);
129129
TEST_CASE(one_error_several_files);
130130
TEST_CASE(showtime_top5_file);
131-
TEST_CASE(showtime_top5_summary);
132131
TEST_CASE(showtime_file);
133-
TEST_CASE(showtime_summary);
134132
TEST_CASE(showtime_file_total);
135133
TEST_CASE(suppress_error_library);
136134
TEST_CASE(unique_errors);
@@ -247,20 +245,6 @@ class TestSingleExecutorBase : public TestFixture {
247245
ASSERT_EQUALS((5 + 1 + 1) * 2LL, cppcheck::count_all_of(output_s, '\n'));
248246
}
249247

250-
void showtime_top5_summary() {
251-
REDIRECT;
252-
check(2, 0,
253-
"int main() {}",
254-
dinit(CheckOptions,
255-
$.showtime = ShowTime::TOP5_SUMMARY));
256-
const std::string output_s = GET_REDIRECT_OUTPUT;
257-
// once: top5 results + newline
258-
ASSERT_EQUALS(5 + 1, cppcheck::count_all_of(output_s, '\n'));
259-
// should only report the top5 once
260-
ASSERT(output_s.find("1 result(s)") == std::string::npos);
261-
ASSERT(output_s.find("2 result(s)") != std::string::npos);
262-
}
263-
264248
void showtime_file() {
265249
REDIRECT;
266250
check(2, 0,
@@ -271,18 +255,6 @@ class TestSingleExecutorBase : public TestFixture {
271255
ASSERT_EQUALS(0, cppcheck::count_all_of(output_s, "Overall time:"));
272256
}
273257

274-
void showtime_summary() {
275-
REDIRECT;
276-
check(2, 0,
277-
"int main() {}",
278-
dinit(CheckOptions,
279-
$.showtime = ShowTime::SUMMARY));
280-
const std::string output_s = GET_REDIRECT_OUTPUT;
281-
// should only report the actual summary once
282-
ASSERT(output_s.find("1 result(s)") == std::string::npos);
283-
ASSERT(output_s.find("2 result(s)") != std::string::npos);
284-
}
285-
286258
void showtime_file_total() {
287259
REDIRECT;
288260
check(2, 0,

test/testthreadexecutor.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ class TestThreadExecutorBase : public TestFixture {
139139
TEST_CASE(one_error_less_files);
140140
TEST_CASE(one_error_several_files);
141141
TEST_CASE(showtime_top5_file);
142-
TEST_CASE(showtime_top5_summary);
143142
TEST_CASE(showtime_file);
144-
TEST_CASE(showtime_summary);
145143
TEST_CASE(showtime_file_total);
146144
TEST_CASE(suppress_error_library);
147145
TEST_CASE(unique_errors);
@@ -255,20 +253,6 @@ class TestThreadExecutorBase : public TestFixture {
255253
ASSERT_EQUALS((5 + 1 + 1) * 2LL, cppcheck::count_all_of(output_s, '\n'));
256254
}
257255

258-
void showtime_top5_summary() {
259-
REDIRECT;
260-
check(2, 2, 0,
261-
"int main() {}",
262-
dinit(CheckOptions,
263-
$.showtime = ShowTime::TOP5_SUMMARY));
264-
const std::string output_s = GET_REDIRECT_OUTPUT;
265-
// once: top5 results + newline
266-
ASSERT_EQUALS(5 + 1, cppcheck::count_all_of(output_s, '\n'));
267-
// should only report the top5 once
268-
ASSERT(output_s.find("1 result(s)") == std::string::npos);
269-
ASSERT(output_s.find("2 result(s)") != std::string::npos);
270-
}
271-
272256
void showtime_file() {
273257
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
274258
check(2, 2, 0,
@@ -279,18 +263,6 @@ class TestThreadExecutorBase : public TestFixture {
279263
ASSERT_EQUALS(0, cppcheck::count_all_of(output_s, "Overall time:"));
280264
}
281265

282-
void showtime_summary() {
283-
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
284-
check(2, 2, 0,
285-
"int main() {}",
286-
dinit(CheckOptions,
287-
$.showtime = ShowTime::SUMMARY));
288-
const std::string output_s = GET_REDIRECT_OUTPUT;
289-
// should only report the actual summary once
290-
ASSERT(output_s.find("1 result(s)") == std::string::npos);
291-
ASSERT(output_s.find("2 result(s)") != std::string::npos);
292-
}
293-
294266
void showtime_file_total() {
295267
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
296268
check(2, 2, 0,

0 commit comments

Comments
 (0)