Hello,
I need help understanding the time output I am getting from a for loop. In the code I am just running a for loop and having the system output the current time to a file.
computer Information (from control panel)
Computer:
processor 1000MHz
999 MHz, 960 MB of RAM
I am using visual studio express 2008 on windows XP.
The code is below
Here is a link to the output text file: http://sharesend.com/p60vp
here is the format of the ouput text file
After I exported the text file to excel, I noticed the following:
My questions are:
1. Why is there a difference in the number of occurrences for each time stamp? For example, why does 12:13:19.296 occur 276 times while 12:13:19.312 occurs 247 times?
2. Why is there a difference when the difference of successive timestamps is calculated. For example, 12:13:19.312 12:13:19.296 = 16 ms but 12:13:19.343 - 12:13:19.328 = 15 ms
I need help understanding the time output I am getting from a for loop. In the code I am just running a for loop and having the system output the current time to a file.
computer Information (from control panel)
Computer:
processor 1000MHz
999 MHz, 960 MB of RAM
I am using visual studio express 2008 on windows XP.
The code is below
Here is a link to the output text file: http://sharesend.com/p60vp
here is the format of the ouput text file
Rich (BB code):
HH:MM:SS*milliSeconds
t *0000* localTime1 is: 12:17:27*812
Rich (BB code):
diff between current time and next time (ms)
276 output lines of 12:13:19.296 00:00:00.016
247 output lines of 12:13:19.312 00:00:00.016
278 output lines of 12:13:19.328 00:00:00.015
276 output lines of 12:13:19.343 00:00:00.016
282 output lines of 12:13:19.359 00:00:00.016
273 output lines of 12:13:19.375 00:00:00.015
287 output lines of 12:13:19.390 00:00:00.016
268 output lines of 12:13:19.406 00:00:00.015
288 output lines of 12:13:19.421 00:00:00.016
290 output lines of 12:13:19.437 00:00:00.016
280 output lines of 12:13:19.453
Rich (BB code):
#include<iostream>
#include<fstream>
#include<iomanip>
#include<windows.h>
usingnamespace std;
int main()
{
SYSTEMTIME localTime0, localTime1, localTime2;
ofstream myFile;
myFile.open("outputFile.txt");
GetLocalTime(&localTime0);
myFile << "Before Counter - localTime0 is: " << setw(2) << setfill('0') << localTime0.wHour <<
":" << setw(2) << setfill('0') << localTime0.wMinute << ":" << setw(2) << setfill('0')
<< localTime0.wSecond << "." << setw(3) << localTime0.wMilliseconds << endl;
myFile << "=============================================\n";
myFile << " HH:MM:SS*milliSeconds" << endl;
for (int t = 0; t < 5000; t++)
{
GetLocalTime(&localTime1);
myFile << "t *" << setw(4) << t << "* " << "localTime1 is: " << setw(2) << setfill('0') <<
localTime1.wHour << ":" << setw(2) << setfill('0') << localTime1.wMinute << ":" <<
setw(2) << setfill('0') << localTime1.wSecond << "*" << setw(3) << setfill('0') << localTime1.wMilliseconds << endl;
}
myFile << endl;
myFile << "=============================================\n";
GetLocalTime(&localTime2);
myFile << "After Counter - localTime2 is: " << setw(2) << setfill('0') << localTime2.wHour <<
":" << setw(2) << setfill('0') << localTime2.wMinute << ":" << setw(2) << setfill('0')
<< localTime2.wSecond << "." << setw(3) << setfill('0') << localTime2.wMilliseconds << endl;
myFile.close();
return 0;
}
1. Why is there a difference in the number of occurrences for each time stamp? For example, why does 12:13:19.296 occur 276 times while 12:13:19.312 occurs 247 times?
2. Why is there a difference when the difference of successive timestamps is calculated. For example, 12:13:19.312 12:13:19.296 = 16 ms but 12:13:19.343 - 12:13:19.328 = 15 ms