From 20d14d5a10c97cd2b1fd6c9f49acd93a90d760f1 Mon Sep 17 00:00:00 2001 From: Jason Booth Date: Tue, 30 Nov 2010 13:08:30 -0500 Subject: [PATCH] Fixed profiler flush not clearing, added 'report' and 'clear' (bug 4674, r=dvander). --- core/logic/Profiler.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/logic/Profiler.cpp b/core/logic/Profiler.cpp index 00bbd596..ad453bae 100644 --- a/core/logic/Profiler.cpp +++ b/core/logic/Profiler.cpp @@ -342,15 +342,46 @@ void ProfileEngine::OnRootConsoleCommand2(const char *cmdname, const ICommandArg GenerateReport(fp); fclose(fp); + + Clear(); rootmenu->ConsolePrint("Profiler report generated as: %s\n", path); return; } + else if (strcmp(command->Arg(2), "report") == 0) + { + FILE *fp; + char path[256]; + + g_pSM->BuildPath(Path_SM, path, sizeof(path), "logs/profile_%d.xml", (int)time(NULL)); + + if ((fp = fopen(path, "wt")) == NULL) + { + rootmenu->ConsolePrint("Failed, could not open file for writing: %s", path); + return; + } + + GenerateReport(fp); + + fclose(fp); + + rootmenu->ConsolePrint("Profiler report generated as: %s\n", path); + return; + } + else if (strcmp(command->Arg(2), "clear") == 0) + { + Clear(); + + rootmenu->ConsolePrint("Profiler statistics cleared.\n"); + return; + } } rootmenu->ConsolePrint("Profiler commands:"); rootmenu->DrawGenericOption("flush", "Flushes statistics to disk and starts over"); + rootmenu->DrawGenericOption("report", "Flushes statistics to disk"); + rootmenu->DrawGenericOption("clear", "Clears statistics"); } bool ProfileEngine::GenerateReport(FILE *fp)