取得自从开机到现在CPU运行的周期数,超毫秒级的精度
2006-02-04 13:35:55 来源:WEB开发网
核心提示:取得自从开机到现在CPU运行的周期数,超毫秒级的精度function Ticker : DWord; register;begin asm push EAX push EDX db $0f,$31 mov Result, EAX pop EDX pop EAX end;end;PRocedure TFo
取得自从开机到现在CPU运行的周期数,超毫秒级的精度 function Ticker : DWord; register; begin asm push EAX push EDX db $0f,$31 mov Result, EAX pop EDX pop EAX end; end;
PRocedure TForm1.Button1Click(Sender: TObject); begin showmessage(inttostr( Ticker)); end;
//rock //转载请保留此信息
作者Blog:http://blog.csdn.net/ypyrock/
相关文章
get CPU id (很全的) |
取得某一dll所有输出函数名 |
取得自从开机到现在CPU运行的周期数,超毫秒级的精度 |
全透明窗体(效果比较好) |
用winspool取得本机安装的打印机的详细信息 | |
black_fox ( 2002-08-23) |
贴老外的贴子。异曲同共之妙。。。 const D32 = $66;
function RDTSC: comp; var TimeStamp : record case byte of 1: (Whole: comp); 2: (Lo, Hi: LongInt); end; begin asm db $0F; db $31; {BASM doesn't support RDTSC} {Pentium RDTSC - Read Time Stamp Counter - instruction} {$ifdef Cpu386} mov [TimeStamp.Lo],eax // the low dword mov [TimeStamp.Hi],edx // the high dword {$else} db D32 mov word ptr TimeStamp.Lo,AX {mov [TimeStamp.Lo],eax - the low dword} db D32 mov word ptr TimeStamp.Hi,DX {mov [TimeStamp.Hi],edx - the high dword} {$endif} end; Result := TimeStamp.Whole; end;
type CompStr = string[25]; {Comps have up to 18 digits, plus commas, and sign}
function CompToStr(N: comp): CompStr; var Low3 : string[3]; N1 : extended; begin if N < 0 then Result := '-' + CompToStr(-N) else begin N1 := N / 1000; Str(Round(Frac(N1) * 1000), Low3); N := Int(N1); if N > 0 then begin while Length(Low3) < 3 do Low3 := '0' + Low3; Result := CompToStr(N) + ThousandSeparator + Low3; end else Result := Low3 end; end;
procedure TForm1.Button1Click(Sender: TObject); begin //showmessage(inttostr( Ticker)); memo1.Lines.Add(CompToStr(RDTSC)); end;
| |