bonjour,
Sous Borland......
J'utilise le compteur de windows , la fonction GetTickCount , mais cette fonction etant peu precise , je voudrais utilisé les autres fonctions associées QueryPerformanceCounter. Mais j'ai des problemes.
[cpp]
//bibliothéque
#include <windows.h>
#include <stdio.h>
//variables globales
int i;
long int tempsInstant;
LARGE_INTEGER *lpFrequency;
LARGE_INTEGER *lpPerformanceCount;
//main
int main(int argc, char* argv[])
{
lpFrequency=50000;
//Initialisation de la frequence
if(0==QueryPerformanceFrequency(lpFrequency))
{
printf("***echec init frequence***\n" );
return 0;
}
//boucle de test retour
for (i=0;i<=100;i++)
{
if(0==QueryPerformanceCounter(lpPerformanceCount))
{
printf("***echec du compteur***\n" );
return 0;
}
printf("%ld\n",lpPerformanceCount);
}
return 0;
}
Mon probleme vient du fait que je n'arrive pas a initialisé ma variable lpFrequency. Borland me fait une erreur de type structure.
Voici les docs de large integer ,QueryPerformanceFrequency et QueryPerformanceCounter.
The LARGE_INTEGER structure is used to represent a 64-bit signed integer value.
typedef union _LARGE_INTEGER {
struct {
DWORD LowPart;
LONG HighPart;
};
LONGLONG QuadPart;
} LARGE_INTEGER;
Members
LowPart
Specifies the low-order 32 bits.
HighPart
Specifies the high-order 32 bits.
QuadPart
Specifies a 64-bit signed integer.
Remarks
The LARGE_INTEGER structure is actually a union. If your compiler has built-in support for 64-bit integers, use the QuadPart member to store the 64-bit integer. Otherwise, use the LowPart and HighPart members to store the 64-bit integer.
The QueryPerformanceFrequency function retrieves the frequency of the high-resolution performance counter, if one exists.
BOOL QueryPerformanceFrequency(
LARGE_INTEGER *lpFrequency // address of current frequency
);
Parameters
lpFrequency
Points to a variable that the function sets, in counts per second, to the current performance-counter frequency. If the installed hardware does not support a high-resolution performance counter, this parameter can be to zero.
Return Values
If the installed hardware supports a high-resolution performance counter, the return value is nonzero.
If the installed hardware does not support a high-resolution performance counter, the return value is zero.
The QueryPerformanceCounter function retrieves the current value of the high-resolution performance counter, if one exists.
BOOL QueryPerformanceCounter(
LARGE_INTEGER *lpPerformanceCount // address of current counter value
);
Parameters
lpPerformanceCount
Points to a variable that the function sets, in counts, to the current performance-counter value. If the installed hardware does not support a high-resolution performance counter, this parameter can be to zero.
Return Values
If the installed hardware supports a high-resolution performance counter, the return value is nonzero.
If the installed hardware does not support a high-resolution performance counter, the return value is zero.
merci d'avance de vos reponses.