Skip to content

ZachWolpe/Pseudo-Profiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ & Python Profiler


Decorators to attach to C++ or Python code to profile runtime characteristics.

Getting Started


C++ Profiler

The C++ profiler contains an Instrumentor class which is responsible for writing timing data to .json. This is then leveraged by the CPUProfiler class to write runtime data. The CPUProfiler decorates a function that you wish to profile.

  1. Include the class declaration in the required source file (preferably using a header file).
#include "[$PATH]/profiler.cpp"
  1. Attached the macro (that calls the CPUProfiler decorator) to the desired code block.
void function() {
  PROFILE_FUNCTION();
  // some function...
};
  1. Compile and build your source code.

  2. Use chrome:https://tracing to upload and analyse the (nearly created) profile.json file.


Python Profiler

  1. Simply attach the decorators @CPUProfiler.profile and @MemoryProfiler.profile to any code and you'll generate the necessary data.

  2. I recommend using snakeviz to view the newly generated .prof file.

    snakeviz [$PATH]/pstats.prof
    

Example

A detailed example is provided on my Medium

: Zach Wolpe
: 10 July 2023

About

A (pseudo) C++ and Python profiler.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published