This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRDTSC_Calculator.dpr
135 lines (120 loc) · 7.12 KB
/
RDTSC_Calculator.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
library RDTSC_Calculator;
{
NNNNNNNNNNNNNNmmmmmmmm+//NmmmmmmdddddddddddddhhddhhhhhhhhhhhhhhdddddddddddddddddmmmmmmmmmmmmmmmNNNNN
NNNNNNNNNmmmmmmmmmdddd/+:mdddddddhdddhhhhhhhhhyhhhyyyyyhhyyyyhhhhhhhhhhhhhddddhddddddmmmmmmmmmmmmmNN
NNNNNNNNmmmddddddddddd/::mddhhhhhhhhhhhddhyyyyyhhyyyyyyyyyyyyyyyyyyyyyhhhhhhhhdddhddddddddmdmmmmmmmm
NNNmmmmmmmdddddmdddhdh/-/dhhhhhhhhhhhyhhhhhysssyyyyyssyyyyysssyyyyyyyyyyyyhhyhhhhhhddddddddddmmmmmmm
NNNmmmmmmmmmmmdddddddh::-hhhhhhhyyyyyyyyyyyysssssssssssyyyssssssyyyyyyyyyyyyyyyyhhhhdhdddddddddmmmmm
NNNmmmmmmmdddddddddhso:--syhhhhysssyyyyyyssssssssssssssssyssssssyyyyyysyyyyyyyyyyyyyhhhhhhdddddddmmm
mmmmdddmmmdddddhhhs/++//+/-shhhyssssssssysssoossssssssssssssssssyssssssssyyyyyyyyyyyyhhhhhhhdddddddd
mmdddddddddddhhhhh//////:--:shyyysssssssssooooosssssssssssssssssssssssssssyyyyssssyyyyyyyyhhhhdddddd
mddddhhhhhhhyyyhhy/:/+/+/.:-/syysssoosssooooooosoooooooooosssooooooooooooooooooosssyyyyyyyyhhhhhhddd
ddddhhhhhhhhyyhyyy-:o/:/+:-:osssoooo+oooooo+++ooooo++++++o++++++oo+++++oooooooossosssyyyyyyhhhhhhhdd
ddhhhhhhhhhhhhhyyo--///::/.-ssooooooooo+++/++++++oo/////++++++++++/+yhhhhhhhhdddhyooossssyyyyyhhhhhd
dhhhhhhhhhhyysssyo-:::///:::+soo++oooo+o+////+++++////////////////shhhhhhhhhhhhhhhho+oosssyyyyyyhhhh
dddhyyyyyssssooss+.:oo+//:--/o++++///++++///:////+//::::::://///+hhhyyyhyhdhhhhhhhdhs/+ossssssyyyyhh
dhhhyysyysssooooo+.:////+::-:+++////////:::::::::://::::::::///odmNNmmhhyhhhdhhhhhddm+/+++ossssyyyhh
dhhhyyssysssso+++/.:/++/+:-::+++////////::----:::::::::----:::omNNMMMNNmhyyyhhhhhhhdmy:/+++oossyyyyh
ddhhyyssssssso++++:++hddhms//////:::::/:-------:::-----------:dNMMMMMMMMNdyyyhhhhhhhdd+:/+oossssyyyh
dhhhhhyyssooso+++oo//syh+/+//////::::::--------------.....---+mNNNNMMMMMMMNdyyyhhhhhddy:/++ooossyyyh
dhhhhhyssooosso+++/-:-/h-./+////+///::::::---------......--.:dNMNNNNMMMMMMMNmhsyhhhhdhd:/++ooosssyyy
yyyyyysoo+osyso+//-:--/y+.:++/////::::--:-----..........----dmMMNNNMMMMMMMMMMMdyyhddhhm///++ossssyyy
yyyssssoooosso+//:-:-//+o--/////:::::-----...............--hdNMMNNNMMMMMMMMMMMMmhyhhhddo///++ooosssy
yyyssysssoooooo++-:-:///s/-:::::---------.....`...........ymNNMMMMMMMMMMMMMMMMMMNmhyhdms:/+++++oooss
yyysosoooo++oo++/::-+///oo--::::----.......````.........-sNMMMMMNNMMNNNNNNNMMMNMMMNdhydh-:/+++ooooss
yysyssssssso++++-:-/+//:/y:-::::--......-.....``..`````-mNNMMMMNNNMMMMMNNNNNMMMMNNMNNdhm-:///++oooss
syysossssooooo+::::+++///oo-:::::-.-......`````````````:NNNNMMMNNMMMMMMMMMNMMMMMMNNNMMNm/:///+++ooss
ysso+oooo+osoo+-/:++++///+s+.::::---.......`````````````sNNNNNNNMMMMMMMMMMNMMMMMMNMNMMMNy:////++ooss
ysooosooo+++++://:+++////:o//-:::---....``.``````````````omNNNmNMMMMMMMMMMMMMMMMMMMMNMMNd/::///+ooss
yyyssso+++/+++./:/++++///::s/--:---.....`````````````-+sdmmmNmmNMMMMMMMMMMMMMMMNNNNNmNNmhdds+://osss
yyysssoo+++++/-/.+o++////::/s:--..--.....``````````/hdmNNNNNmdmNNMMMMMNMMMMMMMNmmddmmmmmddddddhs++os
ysssssssooooo::+:+o+++////:/s/--..--......```````/ydNdmNNNNNNmdmNMMMMMNMMMMNNmddmNNNNNmddddddddmdyss
ysssssysssoo+///:o++++////::oo:-..--.......````.ymdNmmddmmNNNmdmNMMMMNMMMNNNNMMNNNmmdhhdddhdddmmmmmm
hyssssyyssoooo:o-/sooo+///::ss/:--------.....`.ymmNmNdddddmmNNmdNNMMMMMMMNMNNNmdhhhhhhhddhdmmmmmmmNN
ysssssssoooooo:+//sosoo+///:so+:::::::--.....`/mmNNmmdddddmNNNNdmNMMMMNNNNmdhhhhhhhhhhdddddmmmmmmmNN
hyyssssssssoos+o//:+soo+///+o+::://::--.----..hNmNNmddddddmmmNNNdNNNNNNNmddhhhhhdhhddhdmdmmmmmmmmmdm
hyysssssssssoos+oo//++++//sys/:////::-------.+mNmNNmddddhddddNNNmNNNmmmmdddddddddhhddddmdNNNNmmNmdmN
hysssssyyssssssssosyoy+sysys////////:-----:::dmNmNNmmmddhhhdhmNNmNNmmmddhhhhhhddddddmdmNmNNNNNNMNmmN
hyyysyyyysssssoooo+oosssso+++//:////:---:::-ymmNmNNmNmmmddddddmNmNNmmmdddddddddmmmmmmmmNmNNNNNNNmmmN
hhhhyyyyyyyssssoooo++ooo++++//::::////:::::/mmmNNNNNNNmmmmmmmmmNydmmmddmmmmmmmmmNNNmNNmNNNNNNmNmmmmN
dhhhyyyyyyyysssssoooo+++++++/////////:::::-ymmmNNMNMNmNNNmmmmmNN+mmmmmmmmmmmmmNNNmNNNNmNMNMNNNNmmNNN
dhhhhhyyyyyyyyysssooooo++++++////////:::::/NmmNNNMMMNmNNNmmmNNNNhmmmmmNNNNmNNNmNNNmNMNNmNNMNNNNNNNNN
ddhdhhhhyyyyyyyyyssssssoo+++++++++++/////:hmmmNMMMNNNmNNmmmmNNNNNmmmmNNNNNNNNNNNNNNmNMMNmNMMNNNNNNNN
ddhhhhhhyyhyyyyyyyssyyyssoooooooo++++////+mmmmNNMNNMNmNNNNNmmNNmmmmmmNNNNNNNNNMMMMNNmmNNNNMNNNNNNNNN
ddddhhhhhhhyyyyhhyyyyyyysssssssooo++++++/dmmmmNNMMMNNNNNmNNNmmNmmmmmmNNNNNNNmNNNNMMMMNNNNNMNNNNNNNNN
dddhhhhhhhhhyyyhhhhyyyyyyyyyyssoooooooo+sNNNmmNNMMMNNNNNNNNNNNNmmmmmNNNNNNNNmmmNNNNMMMNNNNNNNNNNNNNN
ddddhhhdhhhhhhhhhhhhhyyyyyyyyssssssssss+mmmNNNNNMMMNNNNmNNNNNNmmmmmNNNNNNNNNNmmNNNNNMMMMMMNNNNNNNNNN
ddddddddddhhhhhhhhhhhhhhyyyyyyyyssssssooNmmNNNNNNMMNNNNmNNNNNNmmmmmNNNNMMMNNNNmmmNNNNMMMMNNNMNNNNNNN
dddddddddddhdhhhhhhhhhyyyhhyyyyyyyyyssohNNNmNNNNNNNNNNNNNNmmmmmmmNNNNNNMMMMNNNNmmNNNNNNNNNNNNNNNNNNN
mdddddddddddhddddhhhhhyhhhhhhyhhhhhyyssmNNmmNNNNNNNNNNmNNNmmmmmmNNNNNNNMMMMMNNNNmNNNNNNNNNNNNNNNNNNN
mddddddddddhhdddhhhddhhhhhhhhyyyhhhhyysmNNNNNNNNNNyNNNmNNNmmmmmNNNNNNNNNNMMMMMNNNNNNNNNNNNNNNNNNNNNN
mdddddmmmddddddddddhhhhdddhhhhhhhhhhhysmNNmmNNNNNNmNNNmNNNmmmNNNNNNNNNNNNMMMMMNNNNNNNNMMMNNNNNNNNNNN
mmmmmmmmmmmmmmmdddddddddmmddhhhhhhhhhhsmNNNNNNNNNMMMNNNNNNNNNNNNNNNNNNNNNMMMMMNNNNNNMMMMMMMMNNNNNNNN
mmmmmmmmmmmmmmmmdddddddmmmddddddddhhhhydNNNNNNNNNMNNMNNmNNNNNNNNNNNNNNNNMMMMMMMMNNNNMMMNNNNNNNNNMMMM
___ _ _ _ _ _ __
|_ | | | | (_) | ____ | | / /
| | ___ __ _ ___ | | | |_| |_ ___ _ __ / __ \| |/ / ___ _____ ___ _
| |/ _ \ / _` |/ _ \ | | | | | __/ _ \| '__| / / _` | \ / _ \/ _ \ \ /\ / / | | |
/\__/ / (_) | (_| | (_) | \ \_/ / | || (_) | | | | (_| | |\ \ __/ (_) \ V V /| |_| |
\____/ \___/ \__,_|\___/ \___/|_|\__\___/|_| \ \__,_\_| \_/\___|\___/ \_/\_/ \__,_|
\____/
}
uses
System.SysUtils,
System.Classes,
Windows;
{$R *.res}
function about: string; stdcall;
begin
MessageBox(0, 'RDTSC Calculator By @Keowu', 'Read the documentation on the Official Repo for more information.', 1);
end;
function GetCPUSpeed: string; stdcall;
const
ID_BIT = $200000; // EFLAGS ID bit
DelayTime = 500;
var
TimerHi, TimerLo: DWORD;
PriorityClass, Priority: Integer;
begin
Result := '0';
try
PriorityClass := GetPriorityClass(GetCurrentProcess);
Priority := GetThreadPriority(GetCurrentThread);
SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);
Sleep(10);
asm
dw 310Fh // rdtsc
mov TimerLo, eax
mov TimerHi, edx
end;
Sleep(DelayTime);
asm
dw 310Fh // rdtsc
sub eax, TimerLo
sbb edx, TimerHi
mov TimerLo, eax
mov TimerHi, edx
end;
SetThreadPriority(GetCurrentThread, Priority);
SetPriorityClass(GetCurrentProcess, PriorityClass);
Result := Format('%f MHz', [TimerLo / (1000.0 * DelayTime)]);
except
end;
end;
function GetMemoryUsed: UInt64; stdcall;
var
st: TMemoryManagerState;
sb: TSmallBlockTypeState;
begin
GetMemoryManagerState(st);
result := st.TotalAllocatedMediumBlockSize +
+ st.TotalAllocatedLargeBlockSize;
for sb in st.SmallBlockTypeStates do begin
result := result + sb.UseableBlockSize * sb.AllocatedBlockCount;
end;
end;
exports
GetCPUSpeed, about, GetMemoryUsed;
begin
end.