mirror of
https://github.com/ioquake/jedi-academy.git
synced 2024-11-14 08:50:36 +00:00
62 lines
No EOL
602 B
C++
62 lines
No EOL
602 B
C++
|
|
class timing_c
|
|
{
|
|
private:
|
|
__int64 start;
|
|
__int64 end;
|
|
|
|
int reset;
|
|
public:
|
|
timing_c(void)
|
|
{
|
|
}
|
|
void Start()
|
|
{
|
|
const __int64 *s = &start;
|
|
|
|
__asm
|
|
{
|
|
push eax
|
|
push ebx
|
|
push edx
|
|
|
|
rdtsc
|
|
mov ebx, s
|
|
mov [ebx], eax
|
|
mov [ebx + 4], edx
|
|
|
|
pop edx
|
|
pop ebx
|
|
pop eax
|
|
}
|
|
}
|
|
int End()
|
|
{
|
|
const __int64 *e = &end;
|
|
__int64 time;
|
|
|
|
__asm
|
|
{
|
|
push eax
|
|
push ebx
|
|
push edx
|
|
|
|
rdtsc
|
|
mov ebx, e
|
|
mov [ebx], eax
|
|
mov [ebx + 4], edx
|
|
|
|
pop edx
|
|
pop ebx
|
|
pop eax
|
|
}
|
|
time = end - start;
|
|
if (time < 0)
|
|
{
|
|
time = 0;
|
|
}
|
|
return((int)time);
|
|
}
|
|
};
|
|
|
|
// end
|