This section of the archives stores flipcode's complete Developer Toolbox collection,
featuring a variety of mini-articles and source code contributions from our readers.

Processor Detection Class
Submitted by

Here's my new processor detection class for your code of the day collection. It can detect
Intel and AMD processors, check for all processor extensions (MMX, SSE, ...), measure the
processor frequency and read information about the L1/L2/L3 caches and TLBs. Best of all:
It's just one single source code file containing the C++ class. I think it's useful for
many (game) developers, when coding for MMX or SSE compatible processors or just to
provide the user with detailed information.
Everyone can use the class for free (commercial or not) when he notices my work.
Benjamin Jurke
Germany

// Then we check, if the RDTSC (Real Date Time Stamp Counter) is available.
// This function is necessary for our measure process.
if (!(reg & (1 << 4)))
return 0;

// After that we declare some vars and check the frequency of the high
// resolution timer for the measure process.
// If there's no high-res timer, we exit.
unsigned__int64 starttime, endtime, timedif, freq, start, end, dif;
if (!QueryPerformanceFrequency((LARGE_INTEGER *) &freq))
return 0;

// For the family, model and brand id we can only print the numeric value
sprintf(CPUInfo.strBrandID, "Brand-ID number %d", CPUInfo.uiBrandID);
sprintf(CPUInfo.strFamily, "Family number %d", CPUInfo.uiFamily);
sprintf(CPUInfo.strModel, "Model number %d", CPUInfo.uiModel);