forked from 0ad/0ad
Make Profiler2 configurable in visual mode. Non visual doesn't load the config so it's not possible. Also update the profiler2 page to be able to change the port
Differential Revision: https://code.wildfiregames.com/D2444 This was SVN commit r24340.
This commit is contained in:
parent
d92a2118b0
commit
421fbfd278
@ -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 '+'.
|
||||
|
@ -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;
|
||||
|
||||
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", "127.0.0.1:8000", // bind to localhost for security
|
||||
"num_threads", "6", // enough for the browser's parallel connection limit
|
||||
NULL
|
||||
"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());
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>0 A.D. profiler UI</title>
|
||||
<script src="jquery-1.6.4.js"></script>
|
||||
<script src="utilities.js"></script>
|
||||
@ -45,6 +47,8 @@ header nav p.active { cursor:pointer; background:#eee; box-shadow: 0px 0px 2px 0
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="save_as_file()">Save Live Report to file</button>
|
||||
<label for="gameport">Port:</label>
|
||||
<input id="gameport" type="text" value="8000" onchange="updatePort()">
|
||||
|
||||
<header>
|
||||
<h1>Open reports</h1>
|
||||
|
@ -34,7 +34,7 @@ var g_loading_timeout = null;
|
||||
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 @@ window.onload = function()
|
||||
// add new reports
|
||||
document.getElementById('report_load_input').addEventListener('change', load_report_from_file, false);
|
||||
}
|
||||
|
||||
|
||||
function updatePort() {
|
||||
document.location.reload();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user