forked from qt-creator/qt-creator
Clang: Allow to time high-level functions
...by enabling the logging rule:
qtc.clangbackend.timers=true
Change-Id: I085c6bbebc0343b74bcb90119d1ebb80ad49518d
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
@@ -35,12 +35,15 @@
|
||||
#include <utf8string.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QLoggingCategory>
|
||||
#include <QString>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
namespace {
|
||||
|
||||
Q_LOGGING_CATEGORY(timersLog, "qtc.clangbackend.timers");
|
||||
|
||||
class DebugInspectionDir : public QTemporaryDir
|
||||
{
|
||||
public:
|
||||
@@ -96,4 +99,16 @@ Utf8String debugId(const FileContainer &fileContainer)
|
||||
return id;
|
||||
}
|
||||
|
||||
VerboseScopeDurationTimer::VerboseScopeDurationTimer(const char *id)
|
||||
: id(id)
|
||||
{
|
||||
if (timersLog().isDebugEnabled())
|
||||
timer.start();
|
||||
}
|
||||
|
||||
VerboseScopeDurationTimer::~VerboseScopeDurationTimer()
|
||||
{
|
||||
qCDebug(timersLog) << id << "needed" << timer.elapsed() << "ms";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
#ifndef CLANGBACKENDIPCDEBUGUTILS_H
|
||||
#define CLANGBACKENDIPCDEBUGUTILS_H
|
||||
|
||||
#include "clangbackendipc_global.h"
|
||||
|
||||
#include <QElapsedTimer>
|
||||
|
||||
class FileContainer;
|
||||
class Utf8String;
|
||||
|
||||
@@ -39,6 +43,19 @@ namespace ClangBackEnd {
|
||||
Utf8String debugWriteFileForInspection(const Utf8String &fileContent, const Utf8String &id);
|
||||
Utf8String debugId(const FileContainer &fileContainer);
|
||||
|
||||
class CMBIPC_EXPORT VerboseScopeDurationTimer
|
||||
{
|
||||
public:
|
||||
VerboseScopeDurationTimer(const char *id = 0);
|
||||
~VerboseScopeDurationTimer();
|
||||
|
||||
private:
|
||||
const char * const id;
|
||||
QElapsedTimer timer;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
#define TIME_SCOPE_DURATION(id) ClangBackEnd::VerboseScopeDurationTimer scopeDurationTimer(id)
|
||||
|
||||
#endif // CLANGBACKENDIPCDEBUGUTILS_H
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "connectionclient.h"
|
||||
|
||||
#include "clangbackendipcdebugutils.h"
|
||||
#include "cmbcompletecodecommand.h"
|
||||
#include "cmbregistertranslationunitsforcodecompletioncommand.h"
|
||||
#include "cmbunregistertranslationunitsforcodecompletioncommand.h"
|
||||
@@ -76,6 +77,8 @@ ConnectionClient::~ConnectionClient()
|
||||
|
||||
bool ConnectionClient::connectToServer()
|
||||
{
|
||||
TIME_SCOPE_DURATION("ConnectionClient::connectToServer");
|
||||
|
||||
startProcess();
|
||||
resetProcessAliveTimer();
|
||||
const bool isConnected = connectToLocalSocket();
|
||||
@@ -123,6 +126,8 @@ void ConnectionClient::setProcessAliveTimerInterval(int processTimerInterval)
|
||||
|
||||
void ConnectionClient::startProcess()
|
||||
{
|
||||
TIME_SCOPE_DURATION("ConnectionClient::startProcess");
|
||||
|
||||
if (!isProcessIsRunning()) {
|
||||
connectProcessFinished();
|
||||
connectStandardOutputAndError();
|
||||
@@ -216,6 +221,8 @@ void ConnectionClient::printStandardError()
|
||||
|
||||
void ConnectionClient::finishProcess()
|
||||
{
|
||||
TIME_SCOPE_DURATION("ConnectionClient::finishProcess");
|
||||
|
||||
processAliveTimer.stop();
|
||||
|
||||
disconnectProcessFinished();
|
||||
|
||||
Reference in New Issue
Block a user