2019-05-23 04:20:00 +08:00
|
|
|
/*
|
|
|
|
Copyright (c) 2008-2019 Jan W. Krieger (<jan@jkrieger.de>)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This software is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License (LGPL) as published by
|
|
|
|
the Free Software Foundation, either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License (LGPL) for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License (LGPL)
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-02 21:38:09 +08:00
|
|
|
#include "jkqtcommon/jkqtpdebuggingtools.h"
|
2019-05-23 04:20:00 +08:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int JKQTPAutoOutputTimer::global_indent=0;
|
|
|
|
|
2019-06-21 21:46:53 +08:00
|
|
|
JKQTPAutoOutputTimer::JKQTPAutoOutputTimer(const QString& _message) :
|
|
|
|
QElapsedTimer(),message(_message),indent()
|
2019-05-23 04:20:00 +08:00
|
|
|
{
|
|
|
|
this->indent=QString(global_indent, QLatin1Char(' '));
|
|
|
|
global_indent+=4;
|
|
|
|
#if QT_VERSION >= 0x040800
|
|
|
|
qDebug()<<this->indent<<"TIMER_START: "<<message;
|
|
|
|
#else
|
|
|
|
qDebug()<<this->indent<<"TIMER_START: "<<message;
|
|
|
|
#endif
|
|
|
|
start();
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPAutoOutputTimer::~JKQTPAutoOutputTimer()
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= 0x040800
|
|
|
|
qDebug()<<this->indent<<"TIMER_END: "<<message<<" DUR: "<<double(nsecsElapsed())/1.0e6<<"ms";
|
|
|
|
#else
|
|
|
|
qDebug()<<this->indent<<"TIMER_END: "<<message<<" DUR: "<<double(elapsed())/1.0e3<<"ms";
|
|
|
|
#endif
|
|
|
|
global_indent-=4;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPAutoOutputTimer::write(const QString& message) const {
|
|
|
|
#if QT_VERSION >= 0x040800
|
|
|
|
qDebug()<<this->indent<<"TIMER_MESSAGE: "<<this->message<<" "<<message<<" DUR: "<<double(nsecsElapsed())/1.0e6<<"ms";
|
|
|
|
#else
|
|
|
|
qDebug()<<this->indent<<"TIMER_MESSAGE: "<<this->message<<" "<<message<<" DUR: "<<double(elapsed())/1.0e3<<"ms";
|
|
|
|
#endif
|
|
|
|
}
|