Display a basic summary of benchmark results

This commit is contained in:
Alayan 2024-05-07 17:11:16 +02:00
parent e505d9c686
commit e83fdc9324
No known key found for this signature in database
3 changed files with 62 additions and 2 deletions

View File

@ -269,7 +269,7 @@ void RaceResultGUI::enableAllButtons()
right->setVisible(true);
operations->select("right", PLAYER_ID_GAME_MASTER);
middle->setLabel(_("Save the test results"));
middle->setImage("gui/icons/blue_arrow.png");
middle->setImage("gui/icons/save.png");
middle->setVisible(true);
left->setLabel(_("Back to main menu"));
left->setImage("gui/icons/back.png");
@ -1267,6 +1267,10 @@ void RaceResultGUI::renderGlobal(float dt)
{
displayCTFResults();
}
else if (RaceManager::get()->isBenchmarking())
{
displayBenchmarkSummary();
}
else
{
for (unsigned int i = 0; i < m_all_row_infos.size(); i++)
@ -2282,6 +2286,57 @@ void RaceResultGUI::displayScreenShots()
}
} // displayScreenShots
//-----------------------------------------------------------------------------
void RaceResultGUI::displayBenchmarkSummary()
{
#ifndef SERVER_ONLY
assert(RaceManager::get()->isBenchmarking());
// Draw the title
static video::SColor white_color = video::SColor(255, 255, 255, 255);
gui::IGUIFont* font = GUIEngine::getTitleFont();
int current_x = UserConfigParams::m_width / 2;
RowInfo *ri = &(m_all_row_infos[0]);
int current_y = (int)ri->m_y_pos;
core::stringw title_text = _("Performance Test Results");
core::rect<s32> pos(current_x, current_y, current_x, current_y);
font->draw(title_text.c_str(), pos, white_color, true, true);
// Draw the results
core::dimension2du rect = font->getDimension(title_text.c_str());
current_y += rect.Height;
current_x /= 2;
font = GUIEngine::getFont();
rect = font->getDimension(title_text.c_str());
core::stringw info_text[5];
core::stringw value = StringUtils::toWString(
StringUtils::timeToString(float(profiler.getTotalFrametime())/1000000.0f, 2, true));
info_text[0] = _("Test duration: %s", value);
value = StringUtils::toWString(profiler.getTotalFrames());
info_text[1] = _("Number of frames: %s", value);
value = StringUtils::toWString(profiler.getFPSMetricsLow());
info_text[2] = _("Steady FPS: %s", value);
value = StringUtils::toWString(profiler.getFPSMetricsMid());
info_text[3] = _("Mostly Stable FPS: %s", value); // TODO - better name
value = StringUtils::toWString(profiler.getFPSMetricsHigh());
info_text[4] = _("Typical FPS: %s", value);
for (int i=0; i<5; i++)
{
pos = core::rect<s32>(current_x, current_y, current_x, current_y);
font->draw(info_text[i].c_str(), pos, white_color, true, false);
current_y += (5 * rect.Height) / 4;
}
// TODO : Draw info on the settings
// * resolution
// * Render scale
// * graphics settings
#endif
} // displayBenchmarkSummary
// ----------------------------------------------------------------------------
int RaceResultGUI::getFontHeight() const
{

View File

@ -212,6 +212,7 @@ private:
void displayCTFResults();
void displaySoccerResults();
void drawTeamScorers(KartTeam team, int x, int y, int height);
void displayBenchmarkSummary();
void displayScreenShots();
int getFontHeight () const;

View File

@ -329,6 +329,10 @@ public:
// ------------------------------------------------------------------------
void setDrawing(bool drawing) { m_drawing = drawing; }
int getTotalFrametime() { return m_total_frametime; }
int getTotalFrames() { return m_total_frames; }
int getFPSMetricsHigh() { return m_fps_metrics_high; }
int getFPSMetricsMid() { return m_fps_metrics_mid; }
int getFPSMetricsLow() { return m_fps_metrics_low; }
};
#endif // PROFILER_HPP