Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ 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" ; Bind to localhost for security +server.port = "8000" ; Use a free port on your machine. If port is not 8000 you will need to edit the HTML file in source/tools/profiler2 for it to work. +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: source/ps/Profiler2.cpp =================================================================== --- source/ps/Profiler2.cpp +++ 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()); + LOGMESSAGERENDER("Writing profile data to %s \n", path.string8()); std::ofstream stream(OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc); ENSURE(stream.good());