> Hi
>
[quoted text clipped - 7 lines]
>
> Can anyone help me get started?
You can just use the native
QueryPerformanceCounter/QueryPerformanceFrequency Win32 functions from
managed C++. If you'd rather not #include <windows.h>, you could just
declare them:
#pragma unmanaged
extern "C"
{
int __stdcall QueryPerformanceCounter(__int64* p);
int __stdcall QueryPerformanceFrequency(__int64* p);
}
#pragma managed
To use them, call QueryPerformanceCounter at the start and end of your code
block. Call QueryPerformanceFrequency once to determine the resolution of
the counts.
__int64 start;
__int64 end;
::QueryPerformanceCounter(&start);
//
// Your code to be measured here
//
::QueryPerformanceCounter(&end);
__int64 freq;
::QueryPerformanceFrequency(&freq);
double elapsedSeconds = double(end-start)/freq;
HTH
-cd
ronny - 27 Feb 2005 17:35 GMT
Thanks for your reply Carl. I have tried to add the code you suggested but I
get the following errors
...Include\WinBase.h(9839): error C2733: second C linkage of overloaded
function 'QueryPerformanceCounter' not allowed
...Include\WinBase.h(9846): error C2733: second C linkage of overloaded
function 'QueryPerformanceFrequency' not allowed
...WinBase.h(9844) : see declaration of 'QueryPerformanceFrequency'
I'm not sure if I have added the code to the correct place. My "Form1.h"
looks like this.
***********************************************
#pragma unmanaged
extern "C"
{
int __stdcall QueryPerformanceCounter(__int64* p);
int __stdcall QueryPerformanceFrequency(__int64* p);
}
#pragma managed
#include <stdio.h>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
......
**********************************************
Ronny
>> Hi
>>
[quoted text clipped - 42 lines]
>
> -cd
Carl Daniel [VC++ MVP] - 27 Feb 2005 17:46 GMT
> Thanks for your reply Carl. I have tried to add the code you
> suggested but I get the following errors
[quoted text clipped - 4 lines]
> overloaded function 'QueryPerformanceFrequency' not allowed
> ...WinBase.h(9844) : see declaration of 'QueryPerformanceFrequency'
Just get rid of the re-definition of the functions - you've obviously
already included <windows.h>.
-cd
Carl Daniel [VC++ MVP] - 27 Feb 2005 18:47 GMT
>> Thanks for your reply Carl. I have tried to add the code you
>> suggested but I get the following errors
[quoted text clipped - 7 lines]
> Just get rid of the re-definition of the functions - you've obviously
> already included <windows.h>.
... and you'll have to use LARGE_INTEGER (look it up) instead of __int64.
-cd
ronny - 28 Feb 2005 11:16 GMT
Ok, i've got it working fine now. Thanks for your help.
>>> Thanks for your reply Carl. I have tried to add the code you
>>> suggested but I get the following errors
[quoted text clipped - 11 lines]
>
> -cd
Ioannis Vranos - 28 Feb 2005 14:13 GMT
> Ok, i've got it working fine now. Thanks for your help.
Perhaps you are looking for a .NET profiler? Here is a free one:
http://www.microsoft.com/downloads/details.aspx?FamilyId=86CE6052-D7F4-4AEB-9B7A
-94635BEEBDDA&displaylang=en
It displays time-costs and everything.
And two videos about how to use it:
http://www.microsoft.com/downloads/details.aspx?FamilyId=CD5AA57C-9CD1-45AB-AA4B
-8DC586D30938&displaylang=en

Signature
Ioannis Vranos