From a8dacaa789254005d5c40dd005ecfcd8fb951fdb Mon Sep 17 00:00:00 2001 From: Alem Snyder Date: Sat, 22 Mar 2025 23:12:25 -0700 Subject: [PATCH] add profiling instructions --- README.md | 11 +++++++++-- src/util/voxel.hpp | 2 +- src/world/entity/mesh.hpp | 4 ++-- src/world/terrain/chunk.hpp | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 28ac4335..581cc638 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,20 @@ ninja ./FunGame gprof ./FunGame gmon.out | gprof2dot | dot -Tsvg -o output.svg ``` -Don't know how to turn this off though - +To turn off ```sh rm -rf build # or cmake --fresh ``` +gprof doesn't work with multi-threading. For that we can use perf. + +```sh +perf record -ag ./FunGame Start # or any other commands +perf script report flamegraph # this will ask to download something +firefox flamegraph.html +``` + ## Formatting POSIX shells only diff --git a/src/util/voxel.hpp b/src/util/voxel.hpp index f3f1d327..86dafd49 100644 --- a/src/util/voxel.hpp +++ b/src/util/voxel.hpp @@ -158,7 +158,7 @@ class VoxelObject : VoxelBase { * @return VoxelSize length in x, y, z */ [[nodiscard]] inline VoxelSize - get_size() noexcept { + get_size() const noexcept { return size_; } }; diff --git a/src/world/entity/mesh.hpp b/src/world/entity/mesh.hpp index 451f2c0d..3728fe75 100644 --- a/src/world/entity/mesh.hpp +++ b/src/world/entity/mesh.hpp @@ -153,7 +153,7 @@ class Mesh { template std::optional> analyze_voxel_interface( - T voxel_object, VoxelOffset position, VoxelOffset major_direction, + const T& voxel_object, VoxelOffset position, VoxelOffset major_direction, VoxelOffset minor_direction_1, VoxelOffset minor_direction_2 ) { VoxelColorId voxel_a = voxel_object.get_voxel_color_id(position); @@ -281,7 +281,7 @@ for dimension (x,y,z direction) */ template Mesh -ambient_occlusion_mesher(T voxel_object) { +ambient_occlusion_mesher(const T& voxel_object) { std::vector indicies; std::vector indexed_vertices; std::vector indexed_colors; diff --git a/src/world/terrain/chunk.hpp b/src/world/terrain/chunk.hpp index 81e83e04..c610f2d3 100644 --- a/src/world/terrain/chunk.hpp +++ b/src/world/terrain/chunk.hpp @@ -255,7 +255,7 @@ class ChunkData : public voxel_utility::VoxelBase { * @return VoxelSize vector of Chunk::SIZE */ [[nodiscard]] inline VoxelSize - get_size() { + get_size() const { return {Chunk::SIZE, Chunk::SIZE, Chunk::SIZE}; }