help with a few windows.h functions ?

Hello, I came across this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <windows.h>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{


  LARGE_INTEGER ticksPerSecond;
  LARGE_INTEGER tick;   // A point in time
  LARGE_INTEGER time;   // For converting tick into real time




  // get the high resolution counter's accuracy
  QueryPerformanceFrequency(&ticksPerSecond); 

  // what time is it? (not the local time)
  QueryPerformanceCounter(&tick);

  //printf ("\n Ticks par seconde = %ld",ticksPerSecond.QuadPart);

  // convert the tick number into the number of seconds
  // since the system was started...
  time.QuadPart = tick.QuadPart/ticksPerSecond.QuadPart;


  //get the number of hours
  int hours = time.QuadPart/3600;

  //get the number of minutes
  time.QuadPart = time.QuadPart - (hours * 3600);
  int minutes = time.QuadPart/60;

  //get the number of seconds
  int seconds = time.QuadPart - (minutes * 60);

  double ticks_per_micro= (double)ticksPerSecond.QuadPart/1000000;
  //printf ("\n div = %f",ticks_per_micro);

  //get the number of Microseconds
  double microSecondes = (double)((tick.QuadPart % ticksPerSecond.QuadPart) / ticks_per_micro);

  printf ("\n The system was started %d:%d:%d::%.11f",hours, minutes, seconds, microSecondes);


  }


1) what does QueryPerformanceFrequency() and QueryPerformanceCounter return?
2) what is QuadPart? and it's significance?
QueryPerformanceFrequency(): https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx

This one receives the frequency of the performance counter, i.e. how often the counter polls the process.

QueryPerformanceCounter(): https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx

This one grabs a timestamp of sorts.

LARGE_INTEGER.QuadPart: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383713(v=vs.85).aspx

This is the numerical value of that data represented as a 64-bit integer.

Topic archived. No new replies allowed.