@@ -1438,6 +1438,8 @@ class Game
1438
1438
bool checkConnection ();
1439
1439
bool handleCallbacks ();
1440
1440
void processQueues ();
1441
+ void updateProfilers (const GameRunData &run_data, const RunStats &stats,
1442
+ const FpsControl &draw_times, f32 dtime);
1441
1443
void addProfilerGraphs (const RunStats &stats, const FpsControl &draw_times,
1442
1444
f32 dtime);
1443
1445
void updateStats (RunStats *stats, const FpsControl &draw_times, f32 dtime);
@@ -1574,6 +1576,8 @@ class Game
1574
1576
std::wstring statustext;
1575
1577
1576
1578
KeyCache keycache;
1579
+
1580
+ IntervalLimiter profiler_interval;
1577
1581
};
1578
1582
1579
1583
Game::Game () :
@@ -1722,7 +1726,8 @@ void Game::run()
1722
1726
1723
1727
infotext = L" " ;
1724
1728
hud->resizeHotbar ();
1725
- addProfilerGraphs (stats, draw_times, dtime);
1729
+
1730
+ updateProfilers (runData, stats, draw_times, dtime);
1726
1731
processUserInput (&flags, &runData, dtime);
1727
1732
// Update camera before player movement to avoid camera lag of one frame
1728
1733
updateCameraDirection (&cam_view, &flags);
@@ -2319,6 +2324,34 @@ void Game::processQueues()
2319
2324
}
2320
2325
2321
2326
2327
+ void Game::updateProfilers (const GameRunData &run_data, const RunStats &stats,
2328
+ const FpsControl &draw_times, f32 dtime)
2329
+ {
2330
+ float profiler_print_interval =
2331
+ g_settings->getFloat (" profiler_print_interval" );
2332
+ bool print_to_log = true ;
2333
+
2334
+ if (profiler_print_interval == 0 ) {
2335
+ print_to_log = false ;
2336
+ profiler_print_interval = 5 ;
2337
+ }
2338
+
2339
+ if (profiler_interval.step (dtime, profiler_print_interval)) {
2340
+ if (print_to_log) {
2341
+ infostream << " Profiler:" << std::endl;
2342
+ g_profiler->print (infostream);
2343
+ }
2344
+
2345
+ update_profiler_gui (guitext_profiler, font, text_height,
2346
+ run_data.profiler_current_page , run_data.profiler_max_page );
2347
+
2348
+ g_profiler->clear ();
2349
+ }
2350
+
2351
+ addProfilerGraphs (stats, draw_times, dtime);
2352
+ }
2353
+
2354
+
2322
2355
void Game::addProfilerGraphs (const RunStats &stats,
2323
2356
const FpsControl &draw_times, f32 dtime)
2324
2357
{
0 commit comments