Skip to content

Commit 45ebaa3

Browse files
committedNov 11, 2014
Fix profiler values not being updated (F6) and not being logged
1 parent 0adadba commit 45ebaa3

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed
 

‎src/game.cpp

+34-1
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,8 @@ class Game
14381438
bool checkConnection();
14391439
bool handleCallbacks();
14401440
void processQueues();
1441+
void updateProfilers(const GameRunData &run_data, const RunStats &stats,
1442+
const FpsControl &draw_times, f32 dtime);
14411443
void addProfilerGraphs(const RunStats &stats, const FpsControl &draw_times,
14421444
f32 dtime);
14431445
void updateStats(RunStats *stats, const FpsControl &draw_times, f32 dtime);
@@ -1574,6 +1576,8 @@ class Game
15741576
std::wstring statustext;
15751577

15761578
KeyCache keycache;
1579+
1580+
IntervalLimiter profiler_interval;
15771581
};
15781582

15791583
Game::Game() :
@@ -1722,7 +1726,8 @@ void Game::run()
17221726

17231727
infotext = L"";
17241728
hud->resizeHotbar();
1725-
addProfilerGraphs(stats, draw_times, dtime);
1729+
1730+
updateProfilers(runData, stats, draw_times, dtime);
17261731
processUserInput(&flags, &runData, dtime);
17271732
// Update camera before player movement to avoid camera lag of one frame
17281733
updateCameraDirection(&cam_view, &flags);
@@ -2319,6 +2324,34 @@ void Game::processQueues()
23192324
}
23202325

23212326

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+
23222355
void Game::addProfilerGraphs(const RunStats &stats,
23232356
const FpsControl &draw_times, f32 dtime)
23242357
{

0 commit comments

Comments
 (0)
Please sign in to comment.