Fixed #5306 (Implement --showtime=top5)
This commit is contained in:
parent
7a6386bc4b
commit
ea10a722fc
|
@ -46,8 +46,7 @@ CppCheck::CppCheck(ErrorLogger &errorLogger, bool useGlobalSuppressions)
|
||||||
|
|
||||||
CppCheck::~CppCheck()
|
CppCheck::~CppCheck()
|
||||||
{
|
{
|
||||||
if (_settings._showtime != SHOWTIME_NONE)
|
S_timerResults.ShowResults(_settings._showtime);
|
||||||
S_timerResults.ShowResults();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * CppCheck::version()
|
const char * CppCheck::version()
|
||||||
|
|
|
@ -35,7 +35,7 @@ Settings::Settings()
|
||||||
_xml(false), _xml_version(1),
|
_xml(false), _xml_version(1),
|
||||||
_jobs(1),
|
_jobs(1),
|
||||||
_exitCode(0),
|
_exitCode(0),
|
||||||
_showtime(0),
|
_showtime(SHOWTIME_NONE),
|
||||||
_maxConfigs(12),
|
_maxConfigs(12),
|
||||||
enforcedLang(None),
|
enforcedLang(None),
|
||||||
reportProgress(false),
|
reportProgress(false),
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "suppressions.h"
|
#include "suppressions.h"
|
||||||
#include "standards.h"
|
#include "standards.h"
|
||||||
|
#include "timer.h"
|
||||||
|
|
||||||
/// @addtogroup Core
|
/// @addtogroup Core
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -120,7 +121,7 @@ public:
|
||||||
std::string _outputFormat;
|
std::string _outputFormat;
|
||||||
|
|
||||||
/** @brief show timing information (--showtime=file|summary|top5) */
|
/** @brief show timing information (--showtime=file|summary|top5) */
|
||||||
unsigned int _showtime;
|
SHOWTIME_MODES _showtime;
|
||||||
|
|
||||||
/** @brief List of include paths, e.g. "my/includes/" which should be used
|
/** @brief List of include paths, e.g. "my/includes/" which should be used
|
||||||
for finding include files inside source files. (-I) */
|
for finding include files inside source files. (-I) */
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO:
|
TODO:
|
||||||
- handle SHOWTIME_TOP5 in TimerResults
|
|
||||||
- sort list by time
|
- sort list by time
|
||||||
- do not sort the results alphabetically
|
- do not sort the results alphabetically
|
||||||
- rename "file" to "single"
|
- rename "file" to "single"
|
||||||
|
@ -31,13 +30,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
void TimerResults::ShowResults() const
|
void TimerResults::ShowResults(SHOWTIME_MODES mode) const
|
||||||
{
|
{
|
||||||
|
if (mode == SHOWTIME_NONE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
TimerResultsData overallData;
|
TimerResultsData overallData;
|
||||||
|
|
||||||
std::map<std::string, struct TimerResultsData>::const_iterator I = _results.begin();
|
std::map<std::string, struct TimerResultsData>::const_iterator I = _results.begin();
|
||||||
const std::map<std::string, struct TimerResultsData>::const_iterator E = _results.end();
|
const std::map<std::string, struct TimerResultsData>::const_iterator E = _results.end();
|
||||||
|
size_t item = 0;
|
||||||
while (I != E) {
|
while (I != E) {
|
||||||
const double sec = I->second.seconds();
|
const double sec = I->second.seconds();
|
||||||
const double secAverage = sec / (double)(I->second._numberOfResults);
|
const double secAverage = sec / (double)(I->second._numberOfResults);
|
||||||
|
@ -46,6 +49,9 @@ void TimerResults::ShowResults() const
|
||||||
overallData._clocks += I->second._clocks;
|
overallData._clocks += I->second._clocks;
|
||||||
|
|
||||||
++I;
|
++I;
|
||||||
|
++item;
|
||||||
|
if ((mode == SHOWTIME_TOP5) && (item>=5))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double secOverall = overallData.seconds();
|
const double secOverall = overallData.seconds();
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
enum {
|
enum SHOWTIME_MODES {
|
||||||
SHOWTIME_NONE = 0,
|
SHOWTIME_NONE = 0,
|
||||||
SHOWTIME_FILE,
|
SHOWTIME_FILE,
|
||||||
SHOWTIME_SUMMARY,
|
SHOWTIME_SUMMARY,
|
||||||
|
@ -59,7 +59,7 @@ public:
|
||||||
TimerResults() {
|
TimerResults() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowResults() const;
|
void ShowResults(SHOWTIME_MODES mode) const;
|
||||||
virtual void AddResults(const std::string& str, std::clock_t clocks);
|
virtual void AddResults(const std::string& str, std::clock_t clocks);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue