diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index 41c877939a..c5903197d3 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -135,6 +135,11 @@ skycolor = "0 0 0" session = 60 ; Throttle FPS in running games (prevents 100% CPU workload). menu = 60 ; Throttle FPS in menus only. +[profiler2] +server = "127.0.0.1" +server.port = "8000" ; Use a free port on your machine. +server.threads = "6" ; Enough for the browser's parallel connection limit + [hotkey] ; Each one of the specified keys will trigger the action on the left ; for multiple-key combinations, separate keys with '+'. diff --git a/source/ps/Profiler2.cpp b/source/ps/Profiler2.cpp index 837b2bb60d..e13b14b7f0 100644 --- a/source/ps/Profiler2.cpp +++ b/source/ps/Profiler2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -27,6 +27,7 @@ #include "lib/allocators/shared_ptr.h" #include "lib/os_path.h" #include "ps/CLogger.h" +#include "ps/ConfigDB.h" #include "ps/CStr.h" #include "ps/Profiler2GPU.h" #include "ps/Pyrogenesis.h" @@ -178,10 +179,21 @@ void CProfiler2::EnableHTTP() if (m_MgContext) return; - const char *options[] = { - "listening_ports", "127.0.0.1:8000", // bind to localhost for security - "num_threads", "6", // enough for the browser's parallel connection limit - NULL + CStr listeningPort = "8000"; + CStr listeningServer = "127.0.0.1"; + CStr numThreads = "6"; + if (CConfigDB::IsInitialised()) + { + CFG_GET_VAL("profiler2.server.port", listeningPort); + CFG_GET_VAL("profiler2.server", listeningServer); + CFG_GET_VAL("profiler2.server.threads", numThreads); + } + + std::string listening_ports = fmt::format("{0}:{1}", listeningServer, listeningPort); + const char* options[] = { + "listening_ports", listening_ports.c_str(), + "num_threads", numThreads.c_str(), + nullptr }; m_MgContext = mg_start(MgCallback, this, options); ENSURE(m_MgContext); @@ -922,6 +934,8 @@ const char* CProfiler2::ConstructJSONResponse(std::ostream& stream, const std::s void CProfiler2::SaveToFile() { OsPath path = psLogDir()/"profile2.jsonp"; + debug_printf("Writing profile data to %s \n", path.string8().c_str()); + LOGMESSAGERENDER("Writing profile data to %s \n", path.string8().c_str()); std::ofstream stream(OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc); ENSURE(stream.good()); diff --git a/source/tools/profiler2/Profiler2Report.js b/source/tools/profiler2/Profiler2Report.js index bca763acc0..facc2444b1 100644 --- a/source/tools/profiler2/Profiler2Report.js +++ b/source/tools/profiler2/Profiler2Report.js @@ -91,7 +91,7 @@ function refresh_from_jsonp(callback, content) function refresh_live(callback, file) { $.ajax({ - url: 'http://127.0.0.1:8000/overview', + url: `http://127.0.0.1:${$("#gameport").val()}/overview`, dataType: 'json', success: function (data) { var threads = []; @@ -115,7 +115,7 @@ function refresh_live(callback, file) function refresh_thread(callback, thread, callback_data) { $.ajax({ - url: 'http://127.0.0.1:8000/query', + url: `http://127.0.0.1:${$("#gameport").val()}/query`, dataType: 'json', data: { 'thread': thread.name }, success: function (data) { diff --git a/source/tools/profiler2/profiler2.html b/source/tools/profiler2/profiler2.html index cd863f4b0e..4247000920 100644 --- a/source/tools/profiler2/profiler2.html +++ b/source/tools/profiler2/profiler2.html @@ -1,5 +1,7 @@ +
+