Skip to content

Commit 9970e3a

Browse files
committed
deprecated --showtime=top5 and introduced the modes top5_file and top5_summary / temporarily disabled collecting of timing information in daca / removed test_showtimetop5.sh
1 parent a27b655 commit 9970e3a

17 files changed

+200
-53
lines changed

.github/workflows/CI-unixish.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,6 @@ jobs:
362362
env:
363363
STRICT: 1
364364

365-
- name: Run showtimetop5 tests
366-
run: |
367-
./tools/test_showtimetop5.sh
368-
369365
- name: Run --dump test
370366
run: |
371367
./cppcheck test/testpreprocessor.cpp --dump
@@ -446,7 +442,7 @@ jobs:
446442
447443
- name: Self check
448444
run: |
449-
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
445+
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5_summary -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
450446
ec=0
451447
452448
# early exit

.github/workflows/asan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
- name: Self check
7373
if: false
7474
run: |
75-
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
75+
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5_summary -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
7676
ec=0
7777
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json -DCHECK_INTERNAL cli lib || ec=1
7878
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1

.github/workflows/tsan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: Self check
5959
if: false
6060
run: |
61-
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
61+
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5_summary -D__CPPCHECK__ --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
6262
ec=0
6363
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json -DCHECK_INTERNAL cli lib || ec=1
6464
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1

.github/workflows/ubsan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
# TODO: only fail the step on sanitizer issues
7171
- name: Self check
7272
run: |
73-
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
73+
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5_summary -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
7474
ec=0
7575
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json -DCHECK_INTERNAL cli lib || ec=1
7676
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1

cli/cmdlineparser.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,12 +814,22 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
814814
mSettings.showtime = SHOWTIME_MODES::SHOWTIME_FILE;
815815
else if (showtimeMode == "summary")
816816
mSettings.showtime = SHOWTIME_MODES::SHOWTIME_SUMMARY;
817-
else if (showtimeMode == "top5")
818-
mSettings.showtime = SHOWTIME_MODES::SHOWTIME_TOP5;
819-
else if (showtimeMode.empty())
817+
else if (showtimeMode == "top5") {
818+
mSettings.showtime = SHOWTIME_MODES::SHOWTIME_TOP5_FILE;
819+
printMessage("--showtime=top5 is deprecated and will be removed in Cppcheck 2.13. Please use --showtime=top5_file or --showtime=top5_summary instead.");
820+
}
821+
else if (showtimeMode == "top5_file")
822+
mSettings.showtime = SHOWTIME_MODES::SHOWTIME_TOP5_FILE;
823+
else if (showtimeMode == "top5_summary")
824+
mSettings.showtime = SHOWTIME_MODES::SHOWTIME_TOP5_SUMMARY;
825+
else if (showtimeMode == "none")
820826
mSettings.showtime = SHOWTIME_MODES::SHOWTIME_NONE;
827+
else if (showtimeMode.empty()) {
828+
printError("no mode provided for --showtime");
829+
return false;
830+
}
821831
else {
822-
printError("unrecognized showtime mode: \"" + showtimeMode + "\". Supported modes: file, summary, top5.");
832+
printError("unrecognized --showtime mode: '" + showtimeMode + "'");
823833
return false;
824834
}
825835
}
@@ -1287,7 +1297,20 @@ void CmdLineParser::printHelp()
12871297
" --rule-file=<file> Use given rule file. For more information, see:\n"
12881298
" http://sourceforge.net/projects/cppcheck/files/Articles/\n"
12891299
#endif
1290-
// TODO: document --showtime
1300+
" --showtime=<mode> Show timing information.\n"
1301+
" The available modes are:\n"
1302+
" * none\n"
1303+
" Show nothing (default)\n"
1304+
" * file\n"
1305+
" Show for each processed file\n"
1306+
" * summary\n"
1307+
" Show a summary at the end\n"
1308+
" * top5_file\n"
1309+
" Show the top 5 for each processed file\n"
1310+
" * top5_summary\n"
1311+
" Show the top 5 summary at the end\n"
1312+
" * top5\n"
1313+
" Alias for top5_file (deprecated)\n"
12911314
" --std=<id> Set standard.\n"
12921315
" The available options are:\n"
12931316
" * c89\n"

cli/threadexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ unsigned int ThreadExecutor::check()
194194
return v + f.get();
195195
});
196196

197-
if (mSettings.showtime == SHOWTIME_MODES::SHOWTIME_SUMMARY)
198-
CppCheck::printTimerResultsSummary();
197+
if (mSettings.showtime == SHOWTIME_MODES::SHOWTIME_SUMMARY || mSettings.showtime == SHOWTIME_MODES::SHOWTIME_TOP5_SUMMARY)
198+
CppCheck::printTimerResults(mSettings.showtime);
199199

200200
return result;
201201
}

lib/cppcheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ CppCheck::~CppCheck()
406406
mFileInfo.pop_back();
407407
}
408408

409-
if (mSettings.showtime != SHOWTIME_MODES::SHOWTIME_SUMMARY)
410-
s_timerResults.showResults(mSettings.showtime);
409+
if (mSettings.showtime == SHOWTIME_MODES::SHOWTIME_FILE || mSettings.showtime == SHOWTIME_MODES::SHOWTIME_TOP5_FILE)
410+
printTimerResults(mSettings.showtime);
411411

412412
if (mPlistFile.is_open()) {
413413
mPlistFile << ErrorLogger::plistFooter();
@@ -1859,7 +1859,7 @@ void CppCheck::resetTimerResults()
18591859
s_timerResults.reset();
18601860
}
18611861

1862-
void CppCheck::printTimerResultsSummary()
1862+
void CppCheck::printTimerResults(SHOWTIME_MODES mode)
18631863
{
1864-
s_timerResults.showResults(SHOWTIME_MODES::SHOWTIME_SUMMARY);
1864+
s_timerResults.showResults(mode);
18651865
}

lib/cppcheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger {
148148
void removeCtuInfoFiles(const std::map<std::string, std::size_t>& files);
149149

150150
static void resetTimerResults();
151-
static void printTimerResultsSummary();
151+
static void printTimerResults(SHOWTIME_MODES mode);
152152

153153
private:
154154
/** Are there "simple" rules */

lib/timer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void TimerResults::showResults(SHOWTIME_MODES mode) const
5555
const double sec = iter->second.seconds();
5656
const double secAverage = sec / (double)(iter->second.mNumberOfResults);
5757
overallData.mClocks += iter->second.mClocks;
58-
if ((mode != SHOWTIME_MODES::SHOWTIME_TOP5) || (ordinal<=5)) {
58+
if ((mode != SHOWTIME_MODES::SHOWTIME_TOP5_FILE && mode != SHOWTIME_MODES::SHOWTIME_TOP5_SUMMARY) || (ordinal<=5)) {
5959
std::cout << iter->first << ": " << sec << "s (avg. " << secAverage << "s - " << iter->second.mNumberOfResults << " result(s))" << std::endl;
6060
}
6161
++ordinal;

lib/timer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ enum class SHOWTIME_MODES {
3131
SHOWTIME_NONE = 0,
3232
SHOWTIME_FILE,
3333
SHOWTIME_SUMMARY,
34-
SHOWTIME_TOP5
34+
SHOWTIME_TOP5_SUMMARY,
35+
SHOWTIME_TOP5_FILE
3536
};
3637

3738
class CPPCHECKLIB TimerResultsIntf {

0 commit comments

Comments
 (0)