1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -27,19 +27,19 @@
// the first time start() is called until finish() is called. You should always match your
// start and stop calls up.
//
// This works fine as long as you don't use it with huge numbers of calls. If you call start
// This works fine as long as you don't use it with huge numbers of calls. If you call start
// and stop too many times the overhead of the StopWatch class will start factoring in to your
// results.
//
// How to use:
//
//
// StopWatch timer;
// timer.start("Loop only");
// for(int i = 0; i < 6999075; i++)
// {
// }
// timer.stop("Loop only");
//
//
// timer.start("Loop Plus");
// for(int i = 0; i < 100000; i++)
// {
@ -50,14 +50,14 @@
// timer.finish();
//
// Produces this:
//
//
// Seconds Percentage Calls Description
// 0.02865 9.377% 1 Loop only
// 0.27680 90.59% 1 Loop Plus
// 0.12138 39.72% 100000 Inside loop
//
//
// 0.30553 100 % 1 Total
//
//
// Note that you can have overlapping timers which will make your percentages add up to more than 100%.
#ifndef LOGGING_STOPWATCH_H
#define LOGGING_STOPWATCH_H
@ -75,61 +75,65 @@
namespace logging
{
class StopWatch {
public:
void start(const std::string& message);
bool stop(const std::string& message, const int limit);
void stop(const std::string& message);
void finish();
bool isActive()
{
return fOpenCalls > 0;
}
StopWatch() : fStarted(false), fId(-1), fOpenCalls(0), fOutputToFile(false), fLogFile("") {};
StopWatch(int id) : fStarted(false), fId(id), fOpenCalls(0), fOutputToFile(false), fLogFile("") {};
StopWatch(const std::string& fileName) : fStarted(false), fId(-1), fOpenCalls(0), fOutputToFile(true), fLogFile(fileName) {}
struct ::timeval fTvLast;
int getId() { return fId; }
class StopWatch
{
public:
void start(const std::string& message);
bool stop(const std::string& message, const int limit);
void stop(const std::string& message);
void finish();
private:
class ProcessStats
{
public:
std::string fProcess;
struct timeval fTvProcessStarted;
double fTotalSeconds;
int64_t fStartCount;
int64_t fStopCount;
bool isActive()
{
return fOpenCalls > 0;
}
StopWatch() : fStarted(false), fId(-1), fOpenCalls(0), fOutputToFile(false), fLogFile("") {};
StopWatch(int id) : fStarted(false), fId(id), fOpenCalls(0), fOutputToFile(false), fLogFile("") {};
StopWatch(const std::string& fileName) : fStarted(false), fId(-1), fOpenCalls(0), fOutputToFile(true), fLogFile(fileName) {}
struct ::timeval fTvLast;
int getId()
{
return fId;
}
ProcessStats() : fProcess(""), fTotalSeconds(0.0), fStartCount(0), fStopCount(0) {};
private:
class ProcessStats
{
public:
void processStart()
{
gettimeofday(&fTvProcessStarted, 0);
fStartCount++;
}
std::string fProcess;
struct timeval fTvProcessStarted;
double fTotalSeconds;
int64_t fStartCount;
int64_t fStopCount;
void processStop()
{
struct timeval tvStop;
gettimeofday(&tvStop, 0);
fStopCount++;
fTotalSeconds +=
(tvStop.tv_sec + (tvStop.tv_usec / 1000000.0)) -
(fTvProcessStarted.tv_sec + (fTvProcessStarted.tv_usec / 1000000.0));
ProcessStats() : fProcess(""), fTotalSeconds(0.0), fStartCount(0), fStopCount(0) {};
}
};
void processStart()
{
gettimeofday(&fTvProcessStarted, 0);
fStartCount++;
}
struct timeval fTvStart;
std::vector <ProcessStats> fProcessStats;
bool fStarted;
int fId;
int fOpenCalls;
bool fOutputToFile;
std::string fLogFile;
void processStop()
{
struct timeval tvStop;
gettimeofday(&tvStop, 0);
fStopCount++;
fTotalSeconds +=
(tvStop.tv_sec + (tvStop.tv_usec / 1000000.0)) -
(fTvProcessStarted.tv_sec + (fTvProcessStarted.tv_usec / 1000000.0));
}
};
struct timeval fTvStart;
std::vector <ProcessStats> fProcessStats;
bool fStarted;
int fId;
int fOpenCalls;
bool fOutputToFile;
std::string fLogFile;
};
} // end of logging namespace