• ### Popular Now

• 13
• 15
• 27
• 9
• 9

#### Archived

This topic is now archived and is closed to further replies.

# CompuWare DevPartner Profiler (with VC++ .NET 2003)

This topic is 5100 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m trying out the CompuWare DevPartner Profiler (Community Edition, free) with Visual Studio .NET 2003, and at first I compiled a C program and everything looked great. Then I compiled a C++ program, and the only thing that shows up in the profile are global functions, of which there are only 3, one of which is main. Guess which function gets 100% of the time? You guessed it, main(). So that is useless information. Has anytone else had this problem? Anything I might be doing wrong?

##### Share on other sites
you''re doing something wrong. instrumentation is turned on for the solution, right?

##### Share on other sites
Try rebuilding with profiler and instrumentation selected.

##### Share on other sites
Yes, instrumentation was turned on. I even took the Solution that I already got to profile correctly, removed all of the source and header files from it, put the other source code in that Solution and recompiled, and only the three global functions show up. This morning I tried moving a member function from the inline definition to being defined outside of the class, and that didn''t help anything.

I just wrote up this little thing, and nothing about Foo or bar() show up anywhere in the profile. Only main(), and the global_func()''s.
#include <iostream>#include <ctime>using namespace std;const clock_t how_long = 5 * CLOCKS_PER_SEC;unsigned int global_func1 (){    unsigned int a = 0;    for (int i = 0; i < 1000; i++)    {        unsigned r = rand() ^ (rand() << 15);        if (a & 1)            a += (r * 10);        if (a & 2)            a++;        if (a & 4)            a <<= 1;        if (a & 8)            a += 2;    }    return a;}unsigned int global_func2 (){    unsigned int a = 0;    for (int i = 0; i < 1000; i++)    {        unsigned r = rand() ^ (rand() << 15);        if (a & 1)            a ^= r;        if (a & 2)            a ^= !r;        if (a & 4)            a *= r;        if (a & 8)            a += r;    }    return a;}class Foo{public:    Foo ()        : foo_(0)    {    }    void bar ()    {        for (int i = 0; i < 1000; i++)            foo_ ^= rand() * rand();    }    unsigned value () const { return foo_; }private:    unsigned foo_;};int main (){    Foo foo;    unsigned int result;    clock_t start = clock();    for (;;)    {        result ^= global_func1();        result ^= global_func2();        foo.bar();        if ((clock() - start) > how_long)            break;    }    cout << result << endl;    cout << foo.value() << endl;}

Here is what the profiler outputs (probably not formatted, but whatever).
Method Name	% in Method	% with Children	Called	Averageglobal_func2	33.9	49	517	382.6global_func1	33.5	48.4	517	377.4rand	30	30	2,068,000	0.1main	1.8	100	1	10,571.30clock	0.7	0.7	518	7.9GetSystemTimeAsFileTime	0.1	0.1	520	0.6GetModuleHandleA	0	0	3	23.5WriteFile	0	0	12	4.2RtlAllocateHeap	0	0	68	0.6ExitProcess	0	0	1	33.3GetEnvironmentStringsW	0	0	1	27.5HeapCreate	0	0	1	19.1WideCharToMultiByte	0	0	4	4.2GetFileType	0	0	3	4.8LCMapStringW	0	0	5	2.2GetStringTypeW	0	0	2	4.3GetProcAddress	0	0	1	8.5RtlFreeHeap	0	0	23	0.3GetModuleFileNameA	0	0	1	7.8MultiByteToWideChar	0	0	6	1GetVersionExA	0	0	1	3.7QueryPerformanceCounter	0	0	1	2.6GetStartupInfoA	0	0	1	1.6GetCPInfo	0	0	2	0.6GetStdHandle	0	0	3	0.4SetUnhandledExceptionFilter	0	0	2	0.5RtlSizeHeap	0	0	7	0.1GetACP	0	0	1	0.6FreeEnvironmentStringsA	0	0	1	0.6SetHandleCount	0	0	1	0.3IsProcessorFeaturePresent	0	0	1	0.2GetCommandLineA	0	0	1	0.1GetCurrentProcessId	0	0	1	0.1GetTickCount	0	0	1	0.1GetCurrentThreadId	0	0	1	0.1[Program Start]	0	100	0	0[Thread Start - 644]	0	0	0	0

##### Share on other sites
I reinstalled and now if member functions which are NOT defined inline in the class declaration show up in the profile. In other words, this function would NOT show up in the profile:

class Foo {    // ...    void bar () { ... };    // ...};

But this function would:

class Foo {    // ...    void bar ();    // ...};void Foo::bar () { ... }

Not sure why it matters, but apparently it does. I guess I can''t complain since it''s free

##### Share on other sites
of course it matters...if you''re profiling you''re using a release build and your inline functions are part of the calling function (i.e. main).

"That''s not a bug, it''s a feature!"
--me

##### Share on other sites
quote:
Original post by ChaosEngine
of course it matters...if you''re profiling you''re using a release build and your inline functions are part of the calling function (i.e. main).

"That''s not a bug, it''s a feature!"
--me

So you''re saying that everything just got inlined, and that is why it isn''t showing up in the profile? Okay, but the entire program shouldn''t be inlined, should it? In the simple example, sure, but for a 2500 line program? 2500 lines is not that big, but I still wouldn''t imagine everything being inlined. Or am I wrong there? I added /Ob0 to turn off all inlining except for __forceinline, but still no member functions that are defined inline in the class definition show up in the profile.