2014-02-15 18:49:35 +05:30
|
|
|
#include "BaseProfiler.h"
|
|
|
|
|
2014-02-15 22:45:41 +05:30
|
|
|
#include <QProcess>
|
2014-02-15 23:37:01 +05:30
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
2014-02-15 22:45:41 +05:30
|
|
|
|
2014-02-16 02:56:44 +05:30
|
|
|
BaseProfiler::BaseProfiler(BaseInstance *instance, QObject *parent)
|
2014-02-15 18:49:35 +05:30
|
|
|
: QObject(parent), m_instance(instance)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseProfiler::~BaseProfiler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseProfiler::beginProfiling(MinecraftProcess *process)
|
|
|
|
{
|
|
|
|
beginProfilingImpl(process);
|
|
|
|
}
|
|
|
|
|
2014-02-16 13:24:52 +05:30
|
|
|
void BaseProfiler::abortProfiling()
|
|
|
|
{
|
|
|
|
abortProfiling();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseProfiler::abortProfilingImpl()
|
|
|
|
{
|
|
|
|
if (!m_profilerProcess)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_profilerProcess->terminate();
|
|
|
|
m_profilerProcess->deleteLater();
|
|
|
|
}
|
|
|
|
|
2014-02-15 22:45:41 +05:30
|
|
|
qint64 BaseProfiler::pid(QProcess *process)
|
|
|
|
{
|
2014-02-15 23:37:01 +05:30
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
struct _PROCESS_INFORMATION *procinfo = process->pid();
|
|
|
|
return procinfo->dwProcessId;
|
2014-02-15 22:45:41 +05:30
|
|
|
#else
|
2014-02-15 23:37:01 +05:30
|
|
|
return process->pid();
|
2014-02-15 22:45:41 +05:30
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-02-15 18:49:35 +05:30
|
|
|
BaseProfilerFactory::~BaseProfilerFactory()
|
|
|
|
{
|
|
|
|
}
|