Merge pull request #1525 from Trial97/waitprofiler

Add wait profiler
This commit is contained in:
Alexandru Ionut Tripon 2024-05-18 13:17:24 +03:00 committed by GitHub
commit 3887cfe5df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 79 additions and 0 deletions

View File

@ -48,6 +48,7 @@
#include "pathmatcher/MultiMatcher.h"
#include "pathmatcher/SimplePrefixMatcher.h"
#include "settings/INIFile.h"
#include "tools/GenericProfiler.h"
#include "ui/InstanceWindow.h"
#include "ui/MainWindow.h"
@ -879,6 +880,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// FIXME: what to do with these?
m_profilers.insert("jprofiler", std::shared_ptr<BaseProfilerFactory>(new JProfilerFactory()));
m_profilers.insert("jvisualvm", std::shared_ptr<BaseProfilerFactory>(new JVisualVMFactory()));
m_profilers.insert("generic", std::shared_ptr<BaseProfilerFactory>(new GenericProfilerFactory()));
for (auto profiler : m_profilers.values()) {
profiler->registerSettings(m_settings);
}

View File

@ -443,6 +443,8 @@ set(TOOLS_SOURCES
tools/JVisualVM.h
tools/MCEditTool.cpp
tools/MCEditTool.h
tools/GenericProfiler.cpp
tools/GenericProfiler.h
)
set(META_SOURCES

View File

@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "GenericProfiler.h"
#include "BaseInstance.h"
#include "launch/LaunchTask.h"
#include "settings/SettingsObject.h"
class GenericProfiler : public BaseProfiler {
Q_OBJECT
public:
GenericProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject* parent = 0);
protected:
void beginProfilingImpl(shared_qobject_ptr<LaunchTask> process);
};
GenericProfiler::GenericProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject* parent)
: BaseProfiler(settings, instance, parent)
{}
void GenericProfiler::beginProfilingImpl(shared_qobject_ptr<LaunchTask> process)
{
emit readyToLaunch(tr("Started process: %1").arg(process->pid()));
}
BaseExternalTool* GenericProfilerFactory::createTool(InstancePtr instance, QObject* parent)
{
return new GenericProfiler(globalSettings, instance, parent);
}
#include "GenericProfiler.moc"

View File

@ -0,0 +1,29 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "BaseProfiler.h"
class GenericProfilerFactory : public BaseProfilerFactory {
public:
QString name() const override { return "Generic"; }
void registerSettings([[maybe_unused]] SettingsObjectPtr settings) override{};
BaseExternalTool* createTool(InstancePtr instance, QObject* parent = 0) override;
bool check([[maybe_unused]] QString* error) override { return true; };
bool check([[maybe_unused]] const QString& path, [[maybe_unused]] QString* error) override { return true; };
};