forked from mirrors/0ad
Replace TIMER with PROFILE2
`TIMER` messages where printed to stdout which lead to noise. Refs: #1003
This commit is contained in:
@@ -1416,7 +1416,7 @@ int CMapReader::PollMapGeneration()
|
||||
|
||||
int CMapReader::ParseTerrain()
|
||||
{
|
||||
TIMER(L"ParseTerrain");
|
||||
PROFILE2("ParseTerrain");
|
||||
ScriptRequest rq(pSimulation2->GetScriptInterface());
|
||||
|
||||
// parse terrain from map data
|
||||
@@ -1493,7 +1493,7 @@ if (!Script::GetProperty(rq, val, #prop, out))\
|
||||
|
||||
int CMapReader::ParseEntities()
|
||||
{
|
||||
TIMER(L"ParseEntities");
|
||||
PROFILE2("ParseEntities");
|
||||
ScriptRequest rq(pSimulation2->GetScriptInterface());
|
||||
|
||||
// parse entities from map data
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "gui/SGUIMessage.h"
|
||||
#include "lib/debug.h"
|
||||
#include "lib/file/vfs/vfs_util.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/utf8.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Errors.h"
|
||||
@@ -227,7 +226,6 @@ void CGUIManager::SGUIPage::LoadPage(ScriptContext& scriptContext)
|
||||
PROFILE2("load gui xml");
|
||||
PROFILE2_ATTR("name: %s", name.c_str());
|
||||
|
||||
TIMER(nameW.c_str());
|
||||
if (name.back() == '/')
|
||||
{
|
||||
VfsPath currentDirectory = VfsPath("gui") / nameW;
|
||||
|
||||
@@ -95,22 +95,6 @@ private:
|
||||
const wchar_t* m_description;
|
||||
};
|
||||
|
||||
/**
|
||||
* Measures the time taken to execute code up until end of the current scope;
|
||||
* displays it via debug_printf. Can safely be nested.
|
||||
* Useful for measuring time spent in a function or basic block.
|
||||
* <description> must remain valid over the lifetime of this object;
|
||||
* a string literal is safest.
|
||||
*
|
||||
* Example usage:
|
||||
* void func()
|
||||
* {
|
||||
* TIMER(L"description");
|
||||
* // code to be measured
|
||||
* }
|
||||
**/
|
||||
#define TIMER(description) ScopeTimer UID__(description)
|
||||
|
||||
/**
|
||||
* Measures the time taken to execute code between BEGIN and END markers;
|
||||
* displays it via debug_printf. Can safely be nested.
|
||||
|
||||
@@ -106,6 +106,7 @@ CConsole::~CConsole() = default;
|
||||
|
||||
void CConsole::Init()
|
||||
{
|
||||
PROFILE2("CConsole::Init");
|
||||
// Initialise console history file
|
||||
m_MaxHistoryLines = g_ConfigDB.Get("console.history.size", 200);
|
||||
m_HistoryIgnoreDuplicates = g_ConfigDB.Get("console.history.ignore_duplicates", true);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "lib/posix/posix_dlfcn.h"
|
||||
#include "lib/sysdep/os.h"
|
||||
#include "lib/timer.h"
|
||||
#include "ps/Profiler2.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <sstream>
|
||||
@@ -160,7 +161,7 @@ bool DllLoader::LoadDLL()
|
||||
// postcondition: m_Handle valid or == HANDLE_UNAVAILABLE.
|
||||
if (m_Handle == 0)
|
||||
{
|
||||
TIMER(L"LoadDLL");
|
||||
PROFILE2("LoadDLL");
|
||||
|
||||
std::stringstream errors;
|
||||
m_Handle = LoadAnyVariant(m_Name, errors);
|
||||
|
||||
@@ -20,9 +20,12 @@
|
||||
#include "Config.h"
|
||||
|
||||
#include "lib/timer.h"
|
||||
#include "ps/CConsole.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "ps/ConfigDB.h"
|
||||
#include "ps/GameSetup/CmdLineArgs.h"
|
||||
#include "ps/Profiler2.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
@@ -100,7 +103,7 @@ static void ProcessCommandLineArgs(const CmdLineArgs& args)
|
||||
|
||||
void CONFIG_Init(const CmdLineArgs& args)
|
||||
{
|
||||
TIMER(L"CONFIG_Init");
|
||||
PROFILE2("CONFIG_Init");
|
||||
|
||||
CConfigDB::Initialise();
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ void MountMods(const Paths& paths, const std::vector<CStr>& mods)
|
||||
|
||||
void InitVfs(const CmdLineArgs& args)
|
||||
{
|
||||
TIMER(L"InitVfs");
|
||||
PROFILE2("InitVfs");
|
||||
|
||||
const Paths paths(args);
|
||||
|
||||
@@ -208,18 +208,8 @@ void InitVfs(const CmdLineArgs& args)
|
||||
|
||||
static void InitPs(bool setup_gui, const CStrW& gui_page, ScriptInterface* srcScriptInterface, JS::HandleValue initData)
|
||||
{
|
||||
{
|
||||
// console
|
||||
TIMER(L"ps_console");
|
||||
|
||||
g_Console->Init();
|
||||
}
|
||||
|
||||
// hotkeys
|
||||
{
|
||||
TIMER(L"ps_lang_hotkeys");
|
||||
LoadHotkeys(g_ConfigDB);
|
||||
}
|
||||
g_Console->Init();
|
||||
LoadHotkeys(g_ConfigDB);
|
||||
|
||||
if (!setup_gui)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "ps/Errors.h"
|
||||
#include "ps/Filesystem.h"
|
||||
#include "ps/GameSetup/Config.h"
|
||||
#include "ps/Profiler2.h"
|
||||
#include "ps/Pyrogenesis.h"
|
||||
#include "ps/UserReport.h"
|
||||
#include "ps/VideoMode.h"
|
||||
@@ -203,7 +204,7 @@ void ReportLibraries(const ScriptRequest& rq, JS::HandleValue settings)
|
||||
|
||||
void WriteSystemInfo(Renderer::Backend::IDevice* device, const utsname& un)
|
||||
{
|
||||
TIMER(L"write_sys_info");
|
||||
PROFILE2("WriteSystemInfo");
|
||||
|
||||
OsPath pathname = psLogDir() / "system_info.txt";
|
||||
FILE* f = sys_OpenFile(pathname, "w");
|
||||
@@ -297,7 +298,7 @@ void RunHardwareDetection(bool writeSystemInfoBeforeDetection, Renderer::Backend
|
||||
if (writeSystemInfoBeforeDetection)
|
||||
WriteSystemInfo(device, un);
|
||||
|
||||
TIMER(L"RunHardwareDetection");
|
||||
PROFILE2("RunHardwareDetection");
|
||||
|
||||
ScriptInterface scriptInterface("Engine", "HWDetect", g_ScriptContext);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "ps/ConfigDB.h"
|
||||
#include "ps/Globals.h"
|
||||
#include "ps/KeyName.h"
|
||||
#include "ps/Profiler2.h"
|
||||
|
||||
static bool unified[UNIFIED_LAST - UNIFIED_SHIFT];
|
||||
|
||||
@@ -133,6 +134,7 @@ static void LoadConfigBindings(CConfigDB& configDB)
|
||||
|
||||
void LoadHotkeys(CConfigDB& configDB)
|
||||
{
|
||||
PROFILE2("LoadHotkeys");
|
||||
pressedHotkeys.clear();
|
||||
LoadConfigBindings(configDB);
|
||||
}
|
||||
|
||||
+17
-7
@@ -34,6 +34,7 @@
|
||||
#include "ps/Profiler2.h"
|
||||
#include "ps/Profiler2GPU.h"
|
||||
#include "ps/Pyrogenesis.h"
|
||||
#include "ps/TaskManager.h"
|
||||
#include "third_party/mongoose/mongoose.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -106,11 +107,17 @@ static void* MgCallback(mg_event event, struct mg_connection *conn, const struct
|
||||
|
||||
if (uri == "/download")
|
||||
{
|
||||
profiler->SaveToFile();
|
||||
Threading::TaskManager::GetSingleton().PushTask([&]
|
||||
{
|
||||
profiler->SaveToFile();
|
||||
}).Get();
|
||||
}
|
||||
else if (uri == "/overview")
|
||||
{
|
||||
profiler->ConstructJSONOverview(stream);
|
||||
Threading::TaskManager::GetSingleton().PushTask([&]
|
||||
{
|
||||
profiler->ConstructJSONOverview(stream);
|
||||
}).Get();
|
||||
}
|
||||
else if (uri == "/query")
|
||||
{
|
||||
@@ -130,7 +137,10 @@ static void* MgCallback(mg_event event, struct mg_connection *conn, const struct
|
||||
}
|
||||
std::string thread(buf);
|
||||
|
||||
const char* err = profiler->ConstructJSONResponse(stream, thread);
|
||||
const char* err = Threading::TaskManager::GetSingleton().PushTask([&]
|
||||
{
|
||||
return profiler->ConstructJSONResponse(stream, thread);
|
||||
}).Get();
|
||||
if (err)
|
||||
{
|
||||
mg_printf(conn, "%s (%s)", header400, err);
|
||||
@@ -642,7 +652,7 @@ void rewriteBuffer(u8* buffer, u32& bufferSize)
|
||||
|
||||
void CProfiler2::ConstructJSONOverview(std::ostream& stream)
|
||||
{
|
||||
TIMER(L"profile2 overview");
|
||||
PROFILE2("CProfiler2::ConstructJSONOverview");
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_Mutex);
|
||||
|
||||
@@ -665,7 +675,7 @@ void CProfiler2::ConstructJSONOverview(std::ostream& stream)
|
||||
template<typename V>
|
||||
void RunBufferVisitor(const std::string& buffer, V& visitor)
|
||||
{
|
||||
TIMER(L"profile2 visitor");
|
||||
PROFILE2("Profiler2 RunBufferVisitor");
|
||||
|
||||
// The buffer doesn't necessarily start at the beginning of an item
|
||||
// (we just grabbed it from some arbitrary point in the middle),
|
||||
@@ -817,12 +827,12 @@ public:
|
||||
|
||||
const char* CProfiler2::ConstructJSONResponse(std::ostream& stream, const std::string& thread)
|
||||
{
|
||||
TIMER(L"profile2 query");
|
||||
PROFILE2("CProfiler2::ConstructJSONResponse");
|
||||
|
||||
std::string buffer;
|
||||
|
||||
{
|
||||
TIMER(L"profile2 get buffer");
|
||||
PROFILE2("Profiler2 get buffer");
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_Mutex); // lock against changes to m_Threads or deletions of ThreadStorage
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "ps/Filesystem.h"
|
||||
#include "ps/Game.h"
|
||||
#include "ps/Mod.h"
|
||||
#include "ps/Profiler2.h"
|
||||
#include "ps/Pyrogenesis.h"
|
||||
#include "scriptinterface/JSON.h"
|
||||
#include "scriptinterface/Object.h"
|
||||
@@ -275,7 +276,7 @@ std::optional<SavedGames::LoadResult> SavedGames::Load(const ScriptInterface& sc
|
||||
|
||||
JS::Value SavedGames::GetSavedGames(const ScriptInterface& scriptInterface)
|
||||
{
|
||||
TIMER(L"GetSavedGames");
|
||||
PROFILE2("GetSavedGames");
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
JS::RootedValue games(rq.cx);
|
||||
|
||||
@@ -344,10 +344,6 @@ private:
|
||||
|
||||
SetStatus("connecting");
|
||||
|
||||
#if DEBUG_UPLOADS
|
||||
TIMER(L"CUserReporterWorker request");
|
||||
#endif
|
||||
|
||||
CURLcode err = curl_easy_perform(m_Curl);
|
||||
|
||||
#if DEBUG_UPLOADS
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "ps/GameSetup/CmdLineArgs.h"
|
||||
#include "ps/GameSetup/Paths.h"
|
||||
#include "ps/Mod.h"
|
||||
#include "ps/Profiler2.h"
|
||||
#include "ps/Pyrogenesis.h"
|
||||
#include "ps/Replay.h"
|
||||
#include "ps/Util.h"
|
||||
@@ -116,7 +117,7 @@ void VisualReplay::StoreCacheFile(const ScriptInterface& scriptInterface, JS::Ha
|
||||
|
||||
JS::HandleObject VisualReplay::ReloadReplayCache(const ScriptInterface& scriptInterface, bool compareFiles)
|
||||
{
|
||||
TIMER(L"ReloadReplayCache");
|
||||
PROFILE2("ReloadReplayCache");
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
// Maps the filename onto the index, mtime and size
|
||||
@@ -236,7 +237,7 @@ JS::HandleObject VisualReplay::ReloadReplayCache(const ScriptInterface& scriptIn
|
||||
|
||||
JS::Value VisualReplay::GetReplays(const ScriptInterface& scriptInterface, bool compareFiles)
|
||||
{
|
||||
TIMER(L"GetReplays");
|
||||
PROFILE2("GetReplays");
|
||||
|
||||
ScriptRequest rq(scriptInterface);
|
||||
JS::RootedObject replays(rq.cx, ReloadReplayCache(scriptInterface, compareFiles));
|
||||
@@ -459,7 +460,7 @@ JS::Value VisualReplay::GetReplayAttributes(const ScriptInterface& scriptInterfa
|
||||
|
||||
void VisualReplay::AddReplayToCache(const ScriptInterface& scriptInterface, const CStrW& directoryName)
|
||||
{
|
||||
TIMER(L"AddReplayToCache");
|
||||
PROFILE2("AddReplayToCache");
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
JS::RootedValue replayData(rq.cx, LoadReplayData(scriptInterface, OsPath(directoryName)));
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "lib/secure_crt.h"
|
||||
#include "lib/status.h"
|
||||
#include "lib/tex/tex.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/types.h"
|
||||
#include "maths/Matrix3D.h"
|
||||
#include "ps/CConsole.h"
|
||||
@@ -332,7 +331,7 @@ size_t CRenderer::Internals::VertexAttributesHash::operator()(
|
||||
|
||||
CRenderer::CRenderer(Renderer::Backend::IDevice* device)
|
||||
{
|
||||
TIMER(L"InitRenderer");
|
||||
PROFILE2("InitRenderer");
|
||||
|
||||
m = std::make_unique<Internals>(device);
|
||||
|
||||
|
||||
@@ -298,7 +298,6 @@ public:
|
||||
void reset(const Grid<NavcellData>* terrain, pass_class_t passClass)
|
||||
{
|
||||
PROFILE2("JumpPointCache reset");
|
||||
TIMER(L"JumpPointCache reset");
|
||||
|
||||
m_Width = terrain->m_W;
|
||||
m_Height = terrain->m_H;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "maths/MathUtil.h"
|
||||
#include "ps/Pyrogenesis.h"
|
||||
#include "ps/Profile.h"
|
||||
#include "ps/Profiler2.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Replay.h"
|
||||
#include "ps/Util.h"
|
||||
@@ -280,7 +281,7 @@ void CTurnManager::RewindTimeWarp()
|
||||
|
||||
void CTurnManager::QuickSave(JS::HandleValue GUIMetadata)
|
||||
{
|
||||
TIMER(L"QuickSave");
|
||||
PROFILE2("QuickSave");
|
||||
|
||||
std::stringstream stream;
|
||||
if (!m_Simulation2.SerializeState(stream))
|
||||
@@ -302,7 +303,7 @@ void CTurnManager::QuickSave(JS::HandleValue GUIMetadata)
|
||||
|
||||
void CTurnManager::QuickLoad()
|
||||
{
|
||||
TIMER(L"QuickLoad");
|
||||
PROFILE2("QuickLoad");
|
||||
|
||||
if (m_QuickSaveState.empty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user