UI: Profile initialization
This commit is contained in:
parent
7c5d93b92a
commit
8d3db084e8
@ -24,7 +24,7 @@
|
||||
#include <util/bmem.h>
|
||||
#include <util/dstr.h>
|
||||
#include <util/platform.h>
|
||||
#include <util/profiler.h>
|
||||
#include <util/profiler.hpp>
|
||||
#include <obs-config.h>
|
||||
#include <obs.hpp>
|
||||
|
||||
@ -354,6 +354,7 @@ bool OBSApp::InitGlobalConfig()
|
||||
|
||||
bool OBSApp::InitLocale()
|
||||
{
|
||||
ProfileScope("OBSApp::InitLocale");
|
||||
const char *lang = config_get_string(globalConfig, "General",
|
||||
"Language");
|
||||
|
||||
@ -545,6 +546,8 @@ static void move_basic_to_scene_collections(void)
|
||||
|
||||
void OBSApp::AppInit()
|
||||
{
|
||||
ProfileScope("OBSApp::AppInit");
|
||||
|
||||
if (!InitApplicationBundle())
|
||||
throw "Failed to initialize application bundle";
|
||||
if (!MakeUserDirs())
|
||||
@ -583,6 +586,8 @@ const char *OBSApp::GetRenderModule() const
|
||||
|
||||
bool OBSApp::OBSInit()
|
||||
{
|
||||
ProfileScope("OBSApp::OBSInit");
|
||||
|
||||
bool licenseAccepted = config_get_bool(globalConfig, "General",
|
||||
"LicenseAccepted");
|
||||
OBSLicenseAgreement agreement(nullptr);
|
||||
@ -904,6 +909,7 @@ static auto ProfilerFree = [](void *)
|
||||
profiler_free();
|
||||
};
|
||||
|
||||
static const char *run_program_init = "run_program_init";
|
||||
static int run_program(fstream &logFile, int argc, char *argv[])
|
||||
{
|
||||
int ret = -1;
|
||||
@ -915,6 +921,23 @@ static int run_program(fstream &logFile, int argc, char *argv[])
|
||||
ProfilerFree);
|
||||
|
||||
profiler_start();
|
||||
profile_register_root(run_program_init, 0);
|
||||
|
||||
auto PrintInitProfile = [&]()
|
||||
{
|
||||
auto snap = GetSnapshot();
|
||||
|
||||
profiler_snapshot_filter_roots(snap.get(), [](void *data,
|
||||
const char *name, bool *remove)
|
||||
{
|
||||
*remove = (*static_cast<const char**>(data)) != name;
|
||||
return true;
|
||||
}, static_cast<void*>(&run_program_init));
|
||||
|
||||
profiler_print(snap.get());
|
||||
};
|
||||
|
||||
ScopeProfiler prof{run_program_init};
|
||||
|
||||
QCoreApplication::addLibraryPath(".");
|
||||
|
||||
@ -931,6 +954,9 @@ static int run_program(fstream &logFile, int argc, char *argv[])
|
||||
if (!program.OBSInit())
|
||||
return 0;
|
||||
|
||||
prof.Stop();
|
||||
PrintInitProfile();
|
||||
|
||||
return program.exec();
|
||||
|
||||
} catch (const char *error) {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <util/dstr.h>
|
||||
#include <util/util.hpp>
|
||||
#include <util/platform.h>
|
||||
#include <util/profiler.hpp>
|
||||
#include <graphics/math-defs.h>
|
||||
|
||||
#include "obs-app.hpp"
|
||||
@ -577,6 +578,8 @@ bool OBSBasic::LoadService()
|
||||
|
||||
bool OBSBasic::InitService()
|
||||
{
|
||||
ProfileScope("OBSBasic::InitService");
|
||||
|
||||
if (LoadService())
|
||||
return true;
|
||||
|
||||
@ -728,6 +731,8 @@ bool OBSBasic::InitBasicConfigDefaults()
|
||||
|
||||
bool OBSBasic::InitBasicConfig()
|
||||
{
|
||||
ProfileScope("OBSBasic::InitBasicConfig");
|
||||
|
||||
char configPath[512];
|
||||
|
||||
int ret = GetProfilePath(configPath, sizeof(configPath), "");
|
||||
@ -766,6 +771,8 @@ bool OBSBasic::InitBasicConfig()
|
||||
|
||||
void OBSBasic::InitOBSCallbacks()
|
||||
{
|
||||
ProfileScope("OBSBasic::InitOBSCallbacks");
|
||||
|
||||
signalHandlers.reserve(signalHandlers.size() + 6);
|
||||
signalHandlers.emplace_back(obs_get_signal_handler(), "source_add",
|
||||
OBSBasic::SourceAdded, this);
|
||||
@ -783,6 +790,8 @@ void OBSBasic::InitOBSCallbacks()
|
||||
|
||||
void OBSBasic::InitPrimitives()
|
||||
{
|
||||
ProfileScope("OBSBasic::InitPrimitives");
|
||||
|
||||
obs_enter_graphics();
|
||||
|
||||
gs_render_start(true);
|
||||
@ -805,6 +814,8 @@ void OBSBasic::InitPrimitives()
|
||||
|
||||
void OBSBasic::ResetOutputs()
|
||||
{
|
||||
ProfileScope("OBSBasic::ResetOutputs");
|
||||
|
||||
const char *mode = config_get_string(basicConfig, "Output", "Mode");
|
||||
bool advOut = astrcmpi(mode, "Advanced") == 0;
|
||||
|
||||
@ -823,6 +834,8 @@ void OBSBasic::ResetOutputs()
|
||||
|
||||
void OBSBasic::OBSInit()
|
||||
{
|
||||
ProfileScope("OBSBasic::OBSInit");
|
||||
|
||||
const char *sceneCollection = config_get_string(App()->GlobalConfig(),
|
||||
"Basic", "SceneCollectionFile");
|
||||
char savePath[512];
|
||||
@ -878,9 +891,12 @@ void OBSBasic::OBSInit()
|
||||
|
||||
InitPrimitives();
|
||||
|
||||
disableSaving--;
|
||||
Load(savePath);
|
||||
disableSaving++;
|
||||
{
|
||||
ProfileScope("OBSBasic::Load");
|
||||
disableSaving--;
|
||||
Load(savePath);
|
||||
disableSaving++;
|
||||
}
|
||||
|
||||
TimedCheckForUpdates();
|
||||
loaded = true;
|
||||
@ -921,6 +937,8 @@ void OBSBasic::OBSInit()
|
||||
|
||||
void OBSBasic::InitHotkeys()
|
||||
{
|
||||
ProfileScope("OBSBasic::InitHotkeys");
|
||||
|
||||
struct obs_hotkeys_translations t = {};
|
||||
t.insert = Str("Hotkeys.Insert");
|
||||
t.del = Str("Hotkeys.Delete");
|
||||
@ -986,6 +1004,8 @@ void OBSBasic::HotkeyTriggered(void *data, obs_hotkey_id id, bool pressed)
|
||||
|
||||
void OBSBasic::CreateHotkeys()
|
||||
{
|
||||
ProfileScope("OBSBasic::CreateHotkeys");
|
||||
|
||||
auto LoadHotkeyData = [&](const char *name) -> OBSData
|
||||
{
|
||||
const char *info = config_get_string(basicConfig,
|
||||
@ -2001,6 +2021,8 @@ static inline enum video_format GetVideoFormatFromName(const char *name)
|
||||
|
||||
int OBSBasic::ResetVideo()
|
||||
{
|
||||
ProfileScope("OBSBasic::ResetVideo");
|
||||
|
||||
struct obs_video_info ovi;
|
||||
int ret;
|
||||
|
||||
@ -2052,6 +2074,8 @@ int OBSBasic::ResetVideo()
|
||||
|
||||
bool OBSBasic::ResetAudio()
|
||||
{
|
||||
ProfileScope("OBSBasic::ResetAudio");
|
||||
|
||||
struct obs_audio_info ai;
|
||||
ai.samples_per_sec = config_get_uint(basicConfig, "Audio",
|
||||
"SampleRate");
|
||||
|
Loading…
x
Reference in New Issue
Block a user