Fixed #2709 (Negative times in --showtime summary)
This commit is contained in:
parent
a5854ac0c9
commit
295ba9cc4f
6
Makefile
6
Makefile
|
@ -158,6 +158,7 @@ TESTOBJ = test/options.o \
|
|||
test/testsuppressions.o \
|
||||
test/testsymboldatabase.o \
|
||||
test/testthreadexecutor.o \
|
||||
test/testtimer.o \
|
||||
test/testtoken.o \
|
||||
test/testtokenize.o \
|
||||
test/testuninitvar.o \
|
||||
|
@ -393,7 +394,7 @@ test/testleakautovar.o: test/testleakautovar.cpp lib/tokenize.h lib/errorlogger.
|
|||
test/testmathlib.o: test/testmathlib.cpp lib/mathlib.h lib/config.h test/testsuite.h lib/errorlogger.h lib/suppressions.h test/redirect.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testmathlib.o test/testmathlib.cpp
|
||||
|
||||
test/testmemleak.o: test/testmemleak.cpp lib/tokenize.h lib/errorlogger.h lib/config.h lib/suppressions.h lib/tokenlist.h lib/checkmemoryleak.h lib/check.h lib/token.h lib/settings.h lib/standards.h test/testsuite.h test/redirect.h
|
||||
test/testmemleak.o: test/testmemleak.cpp lib/tokenize.h lib/errorlogger.h lib/config.h lib/suppressions.h lib/tokenlist.h lib/checkmemoryleak.h lib/check.h lib/token.h lib/settings.h lib/standards.h test/testsuite.h test/redirect.h lib/symboldatabase.h lib/mathlib.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testmemleak.o test/testmemleak.cpp
|
||||
|
||||
test/testnonreentrantfunctions.o: test/testnonreentrantfunctions.cpp lib/tokenize.h lib/errorlogger.h lib/config.h lib/suppressions.h lib/tokenlist.h lib/checknonreentrantfunctions.h lib/check.h lib/token.h lib/settings.h lib/standards.h test/testsuite.h test/redirect.h
|
||||
|
@ -444,6 +445,9 @@ test/testsymboldatabase.o: test/testsymboldatabase.cpp test/testsuite.h lib/erro
|
|||
test/testthreadexecutor.o: test/testthreadexecutor.cpp lib/cppcheck.h lib/config.h lib/settings.h lib/suppressions.h lib/standards.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h lib/tokenlist.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testthreadexecutor.o test/testthreadexecutor.cpp
|
||||
|
||||
test/testtimer.o: test/testtimer.cpp lib/timer.h lib/config.h test/testsuite.h lib/errorlogger.h lib/suppressions.h test/redirect.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testtimer.o test/testtimer.cpp
|
||||
|
||||
test/testtoken.o: test/testtoken.cpp test/testsuite.h lib/errorlogger.h lib/config.h lib/suppressions.h test/redirect.h test/testutils.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/token.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testtoken.o test/testtoken.cpp
|
||||
|
||||
|
|
|
@ -33,22 +33,22 @@
|
|||
|
||||
void TimerResults::ShowResults() const
|
||||
{
|
||||
std::clock_t overallClocks = 0;
|
||||
TimerResultsData overallData;
|
||||
|
||||
std::map<std::string, struct TimerResultsData>::const_iterator I = _results.begin();
|
||||
const std::map<std::string, struct TimerResultsData>::const_iterator E = _results.end();
|
||||
|
||||
while (I != E) {
|
||||
const double sec = (double)I->second._clocks / CLOCKS_PER_SEC;
|
||||
const double secAverage = (double)(I->second._clocks / I->second._numberOfResults) / CLOCKS_PER_SEC;
|
||||
const double sec = I->second.seconds();
|
||||
const double secAverage = sec / (double)(I->second._numberOfResults);
|
||||
std::cout << I->first << ": " << sec << "s (avg. " << secAverage << "s - " << I->second._numberOfResults << " result(s))" << std::endl;
|
||||
|
||||
overallClocks += I->second._clocks;
|
||||
overallData._clocks += I->second._clocks;
|
||||
|
||||
++I;
|
||||
}
|
||||
|
||||
const double secOverall = (double)overallClocks / CLOCKS_PER_SEC;
|
||||
const double secOverall = overallData.seconds();
|
||||
std::cout << "Overall time: " << secOverall << "s" << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,11 @@ struct TimerResultsData {
|
|||
: _clocks(0)
|
||||
, _numberOfResults(0) {
|
||||
}
|
||||
|
||||
double seconds() const {
|
||||
double ret = (double)((unsigned long)_clocks) / (double)CLOCKS_PER_SEC;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class CPPCHECKLIB TimerResults : public TimerResultsIntf {
|
||||
|
|
|
@ -39,6 +39,7 @@ SOURCES += $${BASEPATH}/test64bit.cpp \
|
|||
$${BASEPATH}/testsuppressions.cpp \
|
||||
$${BASEPATH}/testsymboldatabase.cpp \
|
||||
$${BASEPATH}/testthreadexecutor.cpp \
|
||||
$${BASEPATH}/testtimer.cpp \
|
||||
$${BASEPATH}/testtoken.cpp \
|
||||
$${BASEPATH}/testtokenize.cpp \
|
||||
$${BASEPATH}/testuninitvar.cpp \
|
||||
|
|
Loading…
Reference in New Issue