From 606e131c25aa7d724ebe0b6c60ff7214f12d9845 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Sat, 29 Sep 2018 18:59:19 +0100 Subject: [PATCH] More stats --- voxel_map.cpp | 1 + voxel_terrain.cpp | 25 +++++++++++++++++++++++++ voxel_terrain.h | 12 +++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/voxel_map.cpp b/voxel_map.cpp index 65cc553..0d6a69d 100644 --- a/voxel_map.cpp +++ b/voxel_map.cpp @@ -17,6 +17,7 @@ VoxelMap::VoxelMap() } VoxelMap::~VoxelMap() { + print_line("Destroying VoxelMap"); clear(); } diff --git a/voxel_terrain.cpp b/voxel_terrain.cpp index bc4982a..ae9bcc6 100644 --- a/voxel_terrain.cpp +++ b/voxel_terrain.cpp @@ -27,6 +27,7 @@ VoxelTerrain::VoxelTerrain() } VoxelTerrain::~VoxelTerrain() { + print_line("Destroying VoxelTerrain"); if(_provider_thread) { memdelete(_provider_thread); } @@ -232,6 +233,13 @@ Dictionary VoxelTerrain::get_statistics() const { d["provider"] = provider; 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; } @@ -466,6 +474,8 @@ void VoxelTerrain::_process() { ERR_FAIL_COND(_map.is_null()); + uint64_t time_before = os.get_ticks_usec(); + // Get viewer location // TODO Transform to local (Spatial Transform) Vector3i viewer_block_pos; @@ -519,9 +529,13 @@ void VoxelTerrain::_process() { 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_viewer_block_pos = viewer_block_pos; + time_before = os.get_ticks_usec(); + // Send block loading requests { VoxelProviderThread::InputData input; @@ -536,6 +550,9 @@ void VoxelTerrain::_process() { _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 { 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 { VoxelMeshUpdater::Input input; @@ -641,6 +661,9 @@ void VoxelTerrain::_process() { _blocks_pending_update.clear(); } + _stats.time_send_update_requests = os.get_ticks_usec() - time_before; + time_before = os.get_ticks_usec(); + // Get mesh updates { { @@ -718,6 +741,8 @@ void VoxelTerrain::_process() { _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())); } diff --git a/voxel_terrain.h b/voxel_terrain.h index 7c81087..537ec56 100644 --- a/voxel_terrain.h +++ b/voxel_terrain.h @@ -63,13 +63,23 @@ public: int dropped_provider_blocks; int dropped_updater_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(): mesh_alloc_time(0), updated_blocks(0), dropped_provider_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) { } };