Minimalistic profiler for C++ projects.
Header-only, cross-platform and compact profiler in 250 lines of code.
Just drop the headers (glw_profiler.h and glw_json.h) into your C++ project and include it into a source file
#include "glw_profiler.h"Licensed under BSD.
git clone https://github.com/yak32/glw_profiler.git
cd glw_profiler
mkdir build
cd build
cmake ..
cmake --build . --target install
./../install/tests
(use Git Bash on Windows)
- Instrument your code with GLW_PROFILE_FUNC macro
- Run your app
- Open chrome://tracing in Chrome
- Load json file with results of tracing
#include "../glw_profiler.h"
using namespace glw_profiler;
Profiler profiler;
#define METHOD() GLW_PROFILE_FUNC(profiler, __FUNCTION__)
float func(){
METHOD();
float sum = 0;
for(int i=0;i<100000;i++)
sum += 2.0f;
return sum;
}
int main(){
profiler.start_profiling();
func();
profiler.stop_profiling();
profiler.save_traces("traces.json");
return 0;
}
C++ 11, standard library, glw_json (included)
Traces are collected in memory, saved after profiling into a json file. Size of a trace structure is 28 bytes (VS 2017, 32bit build)
Run cmake on CMakeLists.txt in tests folder.
Cross-platform C++11 code, tested on 3 platforms - Ubuntu, Windows and MacOS.
