diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js index 6b40b75370..9341df3ec8 100644 --- a/binaries/data/mods/public/gui/session/session.js +++ b/binaries/data/mods/public/gui/session/session.js @@ -99,7 +99,7 @@ function reportPerformance(time) map: Engine.GetMapSettings().Name, profiler: Engine.GetProfilerState() }; - Engine.SubmitUserReport("profile", 1, JSON.stringify(data)); + Engine.SubmitUserReport("profile", 2, JSON.stringify(data)); } function leaveGame() diff --git a/source/ps/Profile.cpp b/source/ps/Profile.cpp index 9561e2d11d..3e107a9d21 100644 --- a/source/ps/Profile.cpp +++ b/source/ps/Profile.cpp @@ -183,13 +183,13 @@ CStr CProfileNodeTable::GetCellText(size_t row, size_t col) } if (col == 2) - sprintf_s(buf, ARRAY_SIZE(buf), "%7.3f", unlogged_time_frame * 1000.0f); + sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", unlogged_time_frame * 1000.0f); else if (col == 3) - sprintf_s(buf, ARRAY_SIZE(buf), "%7.1f", unlogged_mallocs_frame); + sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", unlogged_mallocs_frame); else if (col == 5) - sprintf_s(buf, ARRAY_SIZE(buf), "%7.3f", unlogged_time_turn * 1000.f); + sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", unlogged_time_turn * 1000.f); else if (col == 6) - sprintf_s(buf, ARRAY_SIZE(buf), "%7.1f", unlogged_mallocs_turn); + sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", unlogged_mallocs_turn); return CStr(buf); } @@ -201,22 +201,22 @@ CStr CProfileNodeTable::GetCellText(size_t row, size_t col) return child->GetName(); case 1: - sprintf_s(buf, ARRAY_SIZE(buf), "%5.1f", child->GetFrameCalls()); + sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetFrameCalls()); break; case 2: - sprintf_s(buf, ARRAY_SIZE(buf), "%7.3f", child->GetFrameTime() * 1000.0f); + sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", child->GetFrameTime() * 1000.0f); break; case 3: - sprintf_s(buf, ARRAY_SIZE(buf), "%7.1f", child->GetFrameMallocs()); + sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetFrameMallocs()); break; case 4: - sprintf_s(buf, ARRAY_SIZE(buf), "%5.1f", child->GetTurnCalls()); + sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetTurnCalls()); break; case 5: - sprintf_s(buf, ARRAY_SIZE(buf), "%7.3f", child->GetTurnTime() * 1000.0f); + sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", child->GetTurnTime() * 1000.0f); break; case 6: - sprintf_s(buf, ARRAY_SIZE(buf), "%7.1f", child->GetTurnMallocs()); + sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetTurnMallocs()); break; } return CStr(buf); diff --git a/source/ps/ProfileViewer.cpp b/source/ps/ProfileViewer.cpp index 6dc401021f..bd85c6cd14 100644 --- a/source/ps/ProfileViewer.cpp +++ b/source/ps/ProfileViewer.cpp @@ -208,8 +208,13 @@ void CProfileViewer::RenderProfile() glPushMatrix(); for(size_t col = 0; col < columns.size(); ++col) { + CStr text = columns[col].title; + int w, h; + font.CalculateStringSize(text.FromUTF8(), w, h); glPushMatrix(); - glwprintf(L"%hs", columns[col].title.c_str()); + if (col > 0) // right-align all but the first column + glTranslatef(columns[col].width - w, 0, 0); + glwprintf(L"%hs", text.c_str()); glPopMatrix(); glTranslatef(columns[col].width, 0, 0); } @@ -223,6 +228,19 @@ void CProfileViewer::RenderProfile() { glPushMatrix(); + glDisable(GL_TEXTURE_2D); + if (row % 2) + glColor4ub(255, 255, 255, 16); + else + glColor4ub(0, 0, 0, 16); + glBegin(GL_QUADS); + glVertex2i(-22.f, 2.f); + glVertex2i(estimate_width-22.f, 2.f); + glVertex2i(estimate_width-22.f, 2.f-lineSpacing); + glVertex2i(-22.f, 2.f-lineSpacing); + glEnd(); + glEnable(GL_TEXTURE_2D); + if (table->IsHighlightRow(row)) glColor3ub(255, 128, 128); else @@ -239,8 +257,13 @@ void CProfileViewer::RenderProfile() for(size_t col = 0; col < columns.size(); ++col) { + CStr text = table->GetCellText(row, col); + int w, h; + font.CalculateStringSize(text.FromUTF8(), w, h); glPushMatrix(); - glwprintf(L"%hs", table->GetCellText(row, col).c_str()); + if (col > 0) // right-align all but the first column + glTranslatef(columns[col].width - w, 0, 0); + glwprintf(L"%hs", text.c_str()); glPopMatrix(); glTranslatef(columns[col].width, 0, 0); } @@ -441,7 +464,24 @@ namespace void operator() (AbstractProfileTable* table) { - scriptInterface.SetProperty(root.get(), table->GetTitle().c_str(), DumpRows(table)); + CScriptVal t; + scriptInterface.Eval(L"({})", t); + scriptInterface.SetProperty(t.get(), "cols", DumpCols(table)); + scriptInterface.SetProperty(t.get(), "data", DumpRows(table)); + + scriptInterface.SetProperty(root.get(), table->GetTitle().c_str(), t); + } + + std::vector DumpCols(AbstractProfileTable* table) + { + std::vector titles; + + const std::vector& columns = table->GetColumns(); + + for (size_t c = 0; c < columns.size(); ++c) + titles.push_back(columns[c].title); + + return titles; } CScriptVal DumpRows(AbstractProfileTable* table) @@ -454,14 +494,14 @@ namespace for (size_t r = 0; r < table->GetNumberRows(); ++r) { CScriptVal row; - scriptInterface.Eval("({})", row); + scriptInterface.Eval("([])", row); scriptInterface.SetProperty(data.get(), table->GetCellText(r, 0).c_str(), row); - for (size_t c = 1; c < columns.size(); ++c) - scriptInterface.SetProperty(row.get(), columns[c].title.c_str(), table->GetCellText(r, c)); - if (table->GetChild(r)) - scriptInterface.SetProperty(row.get(), "children", DumpRows(table->GetChild(r))); + scriptInterface.SetPropertyInt(row.get(), 0, DumpRows(table->GetChild(r))); + + for (size_t c = 1; c < columns.size(); ++c) + scriptInterface.SetPropertyInt(row.get(), c, table->GetCellText(r, c)); } return data;