we gottem????
This commit is contained in:
parent
14b4d72d8a
commit
a4a35bd911
5 changed files with 47 additions and 20 deletions
|
|
@ -1 +1,3 @@
|
|||
clang++ -DDEBUG -shared src\tmrtsc.cpp -o build\libtmrtsc.dll -Wall -Wextra -Wpedantic -std=c++11 -g -gcodeview -Wl,-pdb= -L C:\capybara\libclang\x86_64-w64-mingw32\bin -l c++ -l unwind --verbose
|
||||
clang++ -DDEBUG -shared src\tmrtsc.cpp -o build\libtmrtsc.dll -Wall -Wextra -Wpedantic -std=c++11 -g -gcodeview -Wl,-pdb= -L C:\capybara\libclang\x86_64-w64-mingw32\bin -Wl,-Bstatic -l c++ -l unwind --verbose
|
||||
|
||||
REM -lmsvcrt -lucrtbase -lvcruntime140_app
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
clang++ src\test\test.cpp -o build\test.exe -Wall -Wextra -Wpedantic -std=c++11 -g -gcodeview -Wl,-pdb= -L C:\capybara\libclang\x86_64-w64-mingw32\bin -l c++ -l unwind -L D:\Contenido\Capybara\Cositas\tmr\build -l tmrtsc --verbose
|
||||
clang++ -DDEBUG -dynamic src\test\test.cpp -o build\test.exe -Wall -Wextra -Wpedantic -std=c++11 -g -gcodeview -Wl,-pdb= -L C:\capybara\libclang\x86_64-w64-mingw32\bin -L D:\Contenido\Capybara\Cositas\tmr\build -Wl,-Bstatic -l c++ -l unwind -Wl,-Bdynamic -l tmrtsc --verbose
|
||||
|
||||
REM -fms-runtime-lib dll_dbg
|
||||
REM -fms-runtime-lib dll_dbgx
|
||||
REM -lmsvcrt -lucrtbase -lvcruntime140_app
|
||||
|
|
|
|||
|
|
@ -1,7 +1,15 @@
|
|||
#ifdef _WIN64
|
||||
#define UNICODE
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
//#define DllImport __declspec( dllimport )
|
||||
#define DllImport __declspec( dllimport )
|
||||
#define _DEBUG
|
||||
#define _MT
|
||||
#define _DLL
|
||||
/*
|
||||
* #define _MT
|
||||
* #define _DLL
|
||||
* #define _DEBUG
|
||||
*/
|
||||
#include <Windows.h>
|
||||
#include <libloaderapi.h>
|
||||
#endif
|
||||
|
|
@ -15,22 +23,27 @@ using namespace tmr;
|
|||
int main(int argc, char** argv){
|
||||
HMODULE dell;
|
||||
DWORD fracaso;
|
||||
//DllImport TSCTimer* timer;
|
||||
int sleep = 1000;
|
||||
|
||||
dell = LoadLibraryExW(TEXT("libtmrtsc.dll"), NULL, NULL);
|
||||
if (dell == NULL) {
|
||||
fracaso = GetLastError();
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* dell = LoadLibraryExW(TEXT("libtmrtsc.dll"), NULL, NULL);
|
||||
* if (dell == NULL) {
|
||||
* fracaso = GetLastError();
|
||||
* return -1;
|
||||
* }
|
||||
*/
|
||||
TSCTimer* timer = nullptr;
|
||||
fracaso = TSCTimer::getTimer(timer);
|
||||
if(fracaso != OPERATION_SUCCESSFUL)
|
||||
timer = TSCTimer::getTimer();
|
||||
if(timer == nullptr)
|
||||
return -2;
|
||||
uint64_t t1 = timer->getTimeStamp();
|
||||
Sleep(sleep);
|
||||
uint64_t t2 = timer->getTimeStamp();
|
||||
uint64_t fr = timer->getBaseFrequency();
|
||||
std::cout << "Windows Momento: \nt1: " << t1 << " t2: " << " fr: " << fr << std::endl;
|
||||
std::cout << "Siestecita de: " << sleep << " ms" << std::endl;
|
||||
std::cout << "Windows Momento: \nt1: " << t1 << " t2: " << t2 << " fr: " << fr << std::endl;
|
||||
std::cout << "restita: " << t2-t1 << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//TODO juntar heaps?
|
||||
#include "tmrtsc.hpp"
|
||||
|
||||
#if _WIN64
|
||||
|
|
@ -166,25 +167,26 @@ namespace tmr {
|
|||
return (rdxho << 32) + raxlo; //|
|
||||
}
|
||||
|
||||
int TSCTimer::getTimer(TSCTimer* timer) {
|
||||
if (!checkInvariantTSC()) return INVARIANT_TSC_NOT_SUPPORTED;
|
||||
TSCTimer* TSCTimer::getTimer() {
|
||||
if (!checkInvariantTSC()) return nullptr;
|
||||
//TODO debug dis
|
||||
const char vendorNames[2][13] = {
|
||||
{"AuthenticAMD"},
|
||||
{"GenuineIntel"}
|
||||
};
|
||||
char* vendorName = readVendorName();
|
||||
int64_t baseFreq;
|
||||
int64_t baseFreq = ART_NOT_REPORTED;
|
||||
|
||||
if (strcmp(vendorName, vendorNames[1]))
|
||||
if (strcmp(vendorName, vendorNames[1]) == 0)
|
||||
baseFreq = intelRetrieveART();
|
||||
if (baseFreq == ART_NOT_REPORTED)
|
||||
baseFreq = getFreqFromSystem();
|
||||
if (baseFreq < OPERATION_SUCCESSFUL)
|
||||
return CANT_READ_FREQUENCY_FROM_SYSTEM;
|
||||
return nullptr;
|
||||
|
||||
timer = new TSCTimer(vendorName, baseFreq);
|
||||
return OPERATION_SUCCESSFUL;
|
||||
//timer =
|
||||
return new TSCTimer(vendorName, baseFreq);
|
||||
//return OPERATION_SUCCESSFUL;
|
||||
}
|
||||
|
||||
uint64_t TSCTimer::getTimeStamp(){
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@
|
|||
#define _WIN32_WINNT _WIN32_WINNT_WIN10 //0x0A00
|
||||
#define MAX_KEY_LENGTH 255
|
||||
#define MAX_VALUE_NAME 32767
|
||||
#define _DEBUG
|
||||
#define _MT
|
||||
#define _DLL
|
||||
/*
|
||||
* #define _MT
|
||||
* #define _DLL
|
||||
* #define _DEBUG
|
||||
*/
|
||||
#include <Windows.h>
|
||||
#include <winreg.h>
|
||||
#include <stringapiset.h>
|
||||
|
|
@ -77,7 +85,8 @@ namespace tmr {
|
|||
uint64_t readRDTSCP(uint64_t* logicore = nullptr );
|
||||
|
||||
public:
|
||||
static int getTimer(TSCTimer* timer = nullptr);
|
||||
// static int getTimer(TSCTimer* timer = nullptr);
|
||||
static TSCTimer* getTimer();
|
||||
|
||||
uint64_t getTimeStamp();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue