Skip to content

Instantly share code, notes, and snippets.

@coderodde
Created October 11, 2023 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderodde/c9ea63616b5744e341d843a79124cb0e to your computer and use it in GitHub Desktop.
Save coderodde/c9ea63616b5744e341d843a79124cb0e to your computer and use it in GitHub Desktop.
The source file for the ThreadPreemptionCounter.
#include <windows.h>
#include <stdio.h>
#define MAX(X, Y) (((X) < (Y)) ? (Y) : (X))
int main() {
ULONGLONG ta = GetTickCount64();
ULONGLONG maximumDuration = 0;
for (int i = 0; i < 10 * 1000 * 1000; i++) {
ULONGLONG tb = GetTickCount64();
ULONGLONG duration = tb - ta;
maximumDuration = MAX(maximumDuration, duration);
}
printf("%llu\n", maximumDuration);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment