哎呀,怎么取得CPU的速度呀 如题,提供源代码更好 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit UCPUSpd;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, Buttons;type TFormCPUSpeed = class(TForm) PageControl: TPageControl; BitBtnStart: TBitBtn; BitBtnStop: TBitBtn; TabSheet: TTabSheet; LabelCPUSpeed: TLabel; LabelInfo: TLabel; LabelWeb: TLabel; procedure BitBtnStartClick(Sender: TObject); procedure BitBtnStopClick(Sender: TObject); private { Private declarations } Stop: Boolean; public { Public declarations } end;var FormCPUSpeed: TFormCPUSpeed;implementation{$R *.DFM}function GetCPUSpeed: Double;const DelayTime = 500; // measure time in msvar TimerHi, TimerLo: DWORD; PriorityClass, Priority: Integer;begin 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 := TimerLo / (1000.0 * DelayTime);end;procedure TFormCPUSpeed.BitBtnStartClick(Sender: TObject);begin BitBtnStart.Enabled := False; BitBtnStop.Enabled := True; Stop := False; while not Stop do begin LabelCPUSpeed.Caption := Format('CPU speed: %f MHz', [GetCPUSpeed]); Application.ProcessMessages; end; BitBtnStart.Enabled := True; BitBtnStop.Enabled := False;end;procedure TFormCPUSpeed.BitBtnStopClick(Sender: TObject);begin Stop := True;end;end. 去bbs.tsinghua.edu.cn delphi版精华区 问题一两句说不清,关于文本操作的 关于提取数据的问题 带参数启动程序 如何用DELPHI调用JAVA的一段程序或网页表单 字符转整型问题?? 请问DELPHI中SQL语句的批处理是怎么写的? delphi 7 的一个小问题。 如何在Delphi中收、发手机短信?高分求 delphi的反编译情况 如何能够让skinengine的Form显示出标题的Caption(当Form.width比较小时) 我用com作了个测试程序,关闭客户端是要报错误。 构成一个简单的SQL语句
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, Buttons;type
TFormCPUSpeed = class(TForm)
PageControl: TPageControl;
BitBtnStart: TBitBtn;
BitBtnStop: TBitBtn;
TabSheet: TTabSheet;
LabelCPUSpeed: TLabel;
LabelInfo: TLabel;
LabelWeb: TLabel;
procedure BitBtnStartClick(Sender: TObject);
procedure BitBtnStopClick(Sender: TObject);
private
{ Private declarations }
Stop: Boolean;
public
{ Public declarations }
end;var
FormCPUSpeed: TFormCPUSpeed;implementation{$R *.DFM}function GetCPUSpeed: Double;
const
DelayTime = 500; // measure time in ms
var
TimerHi, TimerLo: DWORD;
PriorityClass, Priority: Integer;
begin
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 := TimerLo / (1000.0 * DelayTime);
end;procedure TFormCPUSpeed.BitBtnStartClick(Sender: TObject);
begin
BitBtnStart.Enabled := False;
BitBtnStop.Enabled := True; Stop := False;
while not Stop do
begin
LabelCPUSpeed.Caption := Format('CPU speed: %f MHz', [GetCPUSpeed]);
Application.ProcessMessages;
end; BitBtnStart.Enabled := True;
BitBtnStop.Enabled := False;
end;procedure TFormCPUSpeed.BitBtnStopClick(Sender: TObject);
begin
Stop := True;
end;end.