What is CxxProf?

I would like to introduce you to a project I’ve been working on since some weeks. It’s a manually instrumented Profiling library for C++ named CxxProf. The following text is also included in the project wiki and describes what CxxProf is and what it does.

Project Home: CxxProf on GitHub
Project Wiki: Wiki – Home


  • Easy integration: It just takes a few steps to integrate CxxProf into your project. See the integration-guide for how easy it is.
  • Easily remove the lib during compile time: The interface of CxxProf is macro-based. If you do not define USECXXPROF these macros will be empty and your compiler will take care of not having a single code of CxxProf in your project.
  • Easily remove the lib during runtime: You’re compiling your software with a static library of CxxProf (called cxxprof_static for that reason). This library does not do anything more as providing the interface and loading a CxxProf-plugin with all the functionality. If this plugin is not available, cxxprof_static will do nothing but returning from all methods you call on it. Contrary to USECXXPROF this method keeps some overhead, but it’s kept at a minimum and allows you to change whether your profiling or not at runtime.
  • Support for multithreaded applications: CxxProf stores information about which thread is profiling which activities. This way you can see how your threads interact with each other.
  • Support for distributed systems: The collected data is sent to a central server where it is stored and can be examined. By doing this CxxProf is able to receive data from several applications and showing it alongside of each other. That way it is possible to profile your networked software and what data causes which events.
  • Keep impact on a minimum: To not change the environment which should be profiled CxxProf tries to keep the impact on its hosting software on a minimum. All the above goals are implemented with the best performance and least overhead possible.

What does it provide?


The main part of CxxProf are its Activities. These define sections which are measured. As soon as the context of where the Activity has been created is over, the measurement will be taken and stored.

The following code-snippet will create an Activity which measures the main function and another one which measures just an if-statement:

#include <cxxprof_static/CxxProf.h>

int main()
    return 0;


To define when a certain state of an application is reached it is possible to define marks. A good example would be a video game where marks are set to see where the initialization stops and the gameloop begins:

#include "cxxprof_static/CxxProf.h"

int main()
    CXXPROF_MARK("Game Initialization");

    CXXPROF_MARK("Game Loop");
    return 0;


It sometimes is useful to see how the application develops in reference to something measurable. In a game this could be the update times of the AI in reference to how many units are used:

#include "cxxprof_static/CxxProf.h"

int main()
        CXXPROF_PLOT("NumUnits", getUnitCount());
    return 0;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s