24#ifndef _GEMA_LOG_TIME_H_
25#define _GEMA_LOG_TIME_H_
28#include <QElapsedTimer>
52 qint64 t = _timer.elapsed();
53 double ts = t / 1000.0;
55 if(ts >= 100 || ts <= 0.01)
56 aux =
QString(
" (%1)").
arg(formatTime(ts, _secondIndex));
57 gmTimeMsg(_logger,
QObject::tr(
"%1 [%2] finished in %3 s%4").arg(_msg).arg(_nestLevel).arg(ts).arg(aux));
63 qint64
elapsed()
const {
return _timer.elapsed(); }
65 static QString formatTime(
double time,
QString unit,
bool useConstSizeUnit =
false);
66 static QString formatTime(
double time,
int unitIndex,
bool useConstSizeUnit =
false);
Class representing a category with multiple logging levels.
Definition gmLog.h:58
bool isEnabled(GmLogLevel level) const
Returns true if messages for this log level are enabled, false otherwise.
Definition gmLog.h:64
RAII class used to add the elapsed time to a counter received by reference. Counter is incremented in...
Definition gmLogTime.h:89
QElapsedTimer _timer
Timer used to measure elapsed time.
Definition gmLogTime.h:101
qint64 * _counter
The counter where the elapsed time will be added to.
Definition gmLogTime.h:102
RAII object used to measure the elapsed time of an operation.
Definition gmLogTime.h:37
QElapsedTimer _timer
Timer used to measure elapsed time.
Definition gmLogTime.h:82
static int unitIndex(QString unit)
Returns the index of the unit in the format time table of known units, or -1 if not found.
Definition gmLogTime.h:69
const GmLogCategory & _logger
The logger used to emmit messages.
Definition gmLogTime.h:83
static QString indexFmtUnit(int unitIndex)
Returns the formatted unit (always with 3 characters) for the given unit index returned bu unitIndex(...
Definition gmLogTime.h:72
static const int _secondIndex
The index for the second entry in _timeUnits.
Definition gmLogTime.h:80
static int _nestLevel
A global value storing the current nesting level (GmTimeMsg objects created in the scope of another o...
Definition gmLogTime.h:75
qint64 elapsed() const
Returns the elapsed tim so far in ms.
Definition gmLogTime.h:63
QString _msg
Message title.
Definition gmLogTime.h:84
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of support functions and macros for information logging.
@ GM_TIME
Reporting timing information. New category so as to be easy to disable all timing messages for tests ...
Definition gmLog.h:43
qint64 nsecsElapsed() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const