More stats

This commit is contained in:
Marc Gilleron 2018-09-29 18:59:19 +01:00
parent 9303c652d2
commit 606e131c25
3 changed files with 37 additions and 1 deletions

View File

@ -17,6 +17,7 @@ VoxelMap::VoxelMap()
} }
VoxelMap::~VoxelMap() { VoxelMap::~VoxelMap() {
print_line("Destroying VoxelMap");
clear(); clear();
} }

View File

@ -27,6 +27,7 @@ VoxelTerrain::VoxelTerrain()
} }
VoxelTerrain::~VoxelTerrain() { VoxelTerrain::~VoxelTerrain() {
print_line("Destroying VoxelTerrain");
if(_provider_thread) { if(_provider_thread) {
memdelete(_provider_thread); memdelete(_provider_thread);
} }
@ -232,6 +233,13 @@ Dictionary VoxelTerrain::get_statistics() const {
d["provider"] = provider; d["provider"] = provider;
d["updater"] = updater; d["updater"] = updater;
// Breakdown of time spent in _process
d["time_detect_required_blocks"] = _stats.time_detect_required_blocks;
d["time_send_load_requests"] = _stats.time_send_load_requests;
d["time_process_load_responses"] = _stats.time_process_load_responses;
d["time_send_update_requests"] = _stats.time_send_update_requests;
d["time_process_update_responses"] = _stats.time_process_update_responses;
return d; return d;
} }
@ -466,6 +474,8 @@ void VoxelTerrain::_process() {
ERR_FAIL_COND(_map.is_null()); ERR_FAIL_COND(_map.is_null());
uint64_t time_before = os.get_ticks_usec();
// Get viewer location // Get viewer location
// TODO Transform to local (Spatial Transform) // TODO Transform to local (Spatial Transform)
Vector3i viewer_block_pos; Vector3i viewer_block_pos;
@ -519,9 +529,13 @@ void VoxelTerrain::_process() {
remove_positions_outside_box(_blocks_pending_update, new_box, _dirty_blocks); remove_positions_outside_box(_blocks_pending_update, new_box, _dirty_blocks);
} }
_stats.time_detect_required_blocks = os.get_ticks_usec() - time_before;
_last_view_distance_blocks = _view_distance_blocks; _last_view_distance_blocks = _view_distance_blocks;
_last_viewer_block_pos = viewer_block_pos; _last_viewer_block_pos = viewer_block_pos;
time_before = os.get_ticks_usec();
// Send block loading requests // Send block loading requests
{ {
VoxelProviderThread::InputData input; VoxelProviderThread::InputData input;
@ -536,6 +550,9 @@ void VoxelTerrain::_process() {
_provider_thread->push(input); _provider_thread->push(input);
} }
_stats.time_send_load_requests = os.get_ticks_usec() - time_before;
time_before = os.get_ticks_usec();
// Get block loading responses // Get block loading responses
{ {
const unsigned int bs = _map->get_block_size(); const unsigned int bs = _map->get_block_size();
@ -603,6 +620,9 @@ void VoxelTerrain::_process() {
} }
} }
_stats.time_process_load_responses = os.get_ticks_usec() - time_before;
time_before = os.get_ticks_usec();
// Send mesh updates // Send mesh updates
{ {
VoxelMeshUpdater::Input input; VoxelMeshUpdater::Input input;
@ -641,6 +661,9 @@ void VoxelTerrain::_process() {
_blocks_pending_update.clear(); _blocks_pending_update.clear();
} }
_stats.time_send_update_requests = os.get_ticks_usec() - time_before;
time_before = os.get_ticks_usec();
// Get mesh updates // Get mesh updates
{ {
{ {
@ -718,6 +741,8 @@ void VoxelTerrain::_process() {
_stats.mesh_alloc_time = time_taken; _stats.mesh_alloc_time = time_taken;
} }
_stats.time_process_update_responses = os.get_ticks_usec() - time_before;
//print_line(String("d:") + String::num(_dirty_blocks.size()) + String(", q:") + String::num(_block_update_queue.size())); //print_line(String("d:") + String::num(_dirty_blocks.size()) + String(", q:") + String::num(_block_update_queue.size()));
} }

View File

@ -63,13 +63,23 @@ public:
int dropped_provider_blocks; int dropped_provider_blocks;
int dropped_updater_blocks; int dropped_updater_blocks;
int remaining_main_thread_blocks; int remaining_main_thread_blocks;
uint64_t time_detect_required_blocks;
uint64_t time_send_load_requests;
uint64_t time_process_load_responses;
uint64_t time_send_update_requests;
uint64_t time_process_update_responses;
Stats(): Stats():
mesh_alloc_time(0), mesh_alloc_time(0),
updated_blocks(0), updated_blocks(0),
dropped_provider_blocks(0), dropped_provider_blocks(0),
dropped_updater_blocks(0), dropped_updater_blocks(0),
remaining_main_thread_blocks(0) remaining_main_thread_blocks(0),
time_detect_required_blocks(0),
time_send_load_requests(0),
time_process_load_responses(0),
time_send_update_requests(0),
time_process_update_responses(0)
{ } { }
}; };