Fixed profiler flush not clearing, added 'report' and 'clear' (bug 4674, r=dvander).

This commit is contained in:
Jason Booth 2010-11-30 13:08:30 -05:00
parent 043b2df345
commit 20d14d5a10

View File

@ -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)