2.2.7.8 Profiler


Name

Profiler

Remark

The Profiler class can be used to measure various function calls to identify the slower functions.

Hierarchy

  • Profiler

Examples

EX1

#include <origin.h>
#include <profiler.h>
void Profiler_ex1()
{
    Profiler tempObj; // just need to place this as 1st line in function
    
    vector vSrc;
    matrix mat;
    vSrc.SetSize(500000);
    mat.SetSize(500,1000);
    for(int n=0; n<500000; n++)//Generate 500000 random numbers
    {
    	vSrc[n] = (int)(rnd()*1000000);
    }
    mat.SetByVector(vSrc);
    vSrc.Sort();
    mat.Sort();
   
}

/*
Output:
Top 8 most time consuming functions:
Function Name                  Time(sec)	Num of Calls
<1> rnd                        0.216601 	500000
<2>vectorbase::Sort            0.208894 	1
<3>matrixbase::Sort            0.139992 	1
<4>Profiler::Profiler          0.001828 	1
<5>Project::Profile            0.001770 	1
<6>matrixbase::SetByVector     0.001640 	1
<7>vectorbase::SetSize         0.001071 	1
<8>matrixbase::SetSize         0.000014 	1

It figures out matrix is more efficient than vector in calculating.
*/

Header to Include

Profiler.h

Reference

Members

Name Brief Example
Profiler Default constructor to create an Profiler Examples