Index: ps/trunk/binaries/data/config/default.cfg =================================================================== --- ps/trunk/binaries/data/config/default.cfg +++ ps/trunk/binaries/data/config/default.cfg @@ -135,6 +135,11 @@ 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 '+'. Index: ps/trunk/source/ps/Profiler2.cpp =================================================================== --- ps/trunk/source/ps/Profiler2.cpp +++ ps/trunk/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 @@ 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 @@ 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()); Index: ps/trunk/source/tools/profiler2/Profiler2Report.js =================================================================== --- ps/trunk/source/tools/profiler2/Profiler2Report.js +++ ps/trunk/source/tools/profiler2/Profiler2Report.js @@ -91,7 +91,7 @@ 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_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) { Index: ps/trunk/source/tools/profiler2/profiler2.html =================================================================== --- ps/trunk/source/tools/profiler2/profiler2.html +++ ps/trunk/source/tools/profiler2/profiler2.html @@ -1,5 +1,7 @@ + + 0 A.D. profiler UI @@ -45,6 +47,8 @@ + +

Open reports

@@ -88,4 +92,4 @@

 
-
\ No newline at end of file
+
Index: ps/trunk/source/tools/profiler2/profiler2.js
===================================================================
--- ps/trunk/source/tools/profiler2/profiler2.js
+++ ps/trunk/source/tools/profiler2/profiler2.js
@@ -34,7 +34,7 @@
 function save_as_file()
 {
     $.ajax({
-        url: 'http://127.0.0.1:8000/download',
+        url: `http://127.0.0.1:${$("#gameport").val()}/download`,
         success: function () {
         },
         error: function (jqXHR, textStatus, errorThrown) {
@@ -501,3 +501,8 @@
     // add new reports
     document.getElementById('report_load_input').addEventListener('change', load_report_from_file, false);
 }
+
+
+function updatePort() {
+    document.location.reload();
+}