Welp, I did a bit of researching about something called the QueryPerformanceCounter function which, as the name implies, queries a counter inside the CPU for really high-res timing. Here's my code with it so far (for Visual Studio C++):
Code:
#include "stdafx.h"
#include <windows.h>
#include <winbase.h>
#include <stdlib.h>
#include <conio.h>
int main(void)
{
unsigned long int revs=0;
LARGE_INTEGER total_time,diff_time,start_time,end_time,TICKS_PER_SECOND;
char c=0;
FILE *outp;
QueryPerformanceFrequency(&TICKS_PER_SECOND);
total_time.QuadPart=0;
outp=fopen("output.csv","a");
fflush(stdin);
printf("QPC Freq: %I64d\n",TICKS_PER_SECOND.QuadPart);
printf("Press any key to begin capturing.\n");
getch();
printf("Capturing counts to output.csv, press 'x' to quit...");
QueryPerformanceCounter(&start_time);
while(c!='x')
{
if(kbhit())
{
QueryPerformanceCounter(&end_time);
diff_time.QuadPart=end_time.QuadPart-start_time.QuadPart;
total_time.QuadPart+=diff_time.QuadPart;
QueryPerformanceCounter(&start_time);
revs++;
fprintf(outp,"%ld,%I64d,%I64d,\n",revs,total_time.QuadPart,diff_time.QuadPart);
c=getch();
}
}
fclose(outp);
printf("\n\nTotal of %ld revolutions were counted!\n",revs);
getch();
return EXIT_SUCCESS;
}
It will tell you how many ticks per second at the beginning, and then append the results into an "output.csv" file in the same directory as the executable(will be created if it hasn't already). You can later multiply (number of ticks * (1/tick frequency)) to get the time.
I really have no idea how accurate it is, and I'm not a professional programmer by any stretch of the imagination. I'm sure someone will chime in with a better solution. Personally I prefer a microcontroller because you can manually calculate it's timing down to the nanosecond, but a general goes to war with the army he's got...