godotengine / godotengine/godot-cpp

Compute profiling signatures at compile-time

Open
#378 1 comment 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

While I skimmed randomly this repo I found out this file:
https://github.com/GodotNativeTools/godot-cpp/blob/master/include/core/GodotProfiling.hpp
It's late here but I have a suggestion I thought noting down.

I believe one key of profiling is to be as lightweight as possible, especially with languages that run really fast like C++.
Here, `snprintf` is used, and this may induce overhead (especially in nested cases), to print *constant data at runtime* into a static buffer which may be either too large in majority of cases, or too small in worst cases.

I believe `snprintf` can be removed. Instead, macros can do all that work, at compilation time. Then the only thing `FunctionProfiling` needs is a pointer to the compile-time string, and no buffer.
Example of how I did to obtain that string with my own small profiler: https://github.com/Zylann/godot_voxel/blob/9f7a081dd409e703dff6bb9318cef99cb297b5f3/util/zprofiling.h#L14

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.