Help end child hunger

Profile Lib Specification

Prev: In Action Next: Header

VSProfileLib has actually very few methods, so this section will be fairly short. As mentioned in the previous section, PROFILE and PROFILE_GL are just defines for the instance constructor. Each profile segment creates an instance when it starts, and destroys it when it finishes, hence the curly brackets. The curly brackets define the scope where the instance variable will live.

What to profile is controlled by VSPL_PROFILE. There are three options for this constant:

  • VSPL_PROFILE_NONE: no profiling is performed
  • VSPL_PROFILE_CPU: CPU profiling only
  • VSPL_PROFILE_CPU_AND_GPU: profile both CPU and GPU (default value)

The following statement can be found at the beginning of vspl.h:


To change the profiler behaviour just change VSPL_PROFILE.

VSProfileLib allows the usage of several clocks. In addition to the standard C clock function, we can select Unix gettimeofday, and Windows QueryPerformanceCounter and GetSystemTime.

The header file contains the following defines:

#define VSPL_C_CLOCK 0

To select a clock define VSPL_CLOCK. By default VSPL will use the standard C clock function, as the following line from the header shows:


To select a different clock just replace VSPL_C_CLOCK by the defined constant for your selection.

Class Methods

static void Reset();

Function to reset all the profiler counters.



static void CollectQueryResults();

Collects the OpenGL time queries. Use this at the end of the frame. VSProfileLib uses a double buffering scheme for the queries, as detailed in the tutorial. A string with the results can then be obtained with DumpLevels.



static const std::string &DumpLevels();

Returns a string with the profile report. This function can be called anytime, anywhere. There is no need to initialize the class. This string can then be printed on top of an OpenGL application with VSFontLib.


std::string s = VSProfileLib::DumpLevels();


Prev: In Action Next: Header

 Leave a Reply




You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>