آموزش کامپیوتر دلفی و پروژه های دانشجویی رایگان

وابلاگ عاشقان اهل بیت و اموزش کامپیوتر

آموزش کامپیوتر دلفی و پروژه های دانشجویی رایگان

وابلاگ عاشقان اهل بیت و اموزش کامپیوتر

تعیین مقدار بار cpu

برای تعیین مقدار مشغولی cpu از کد زیر استفاده کنید

Get CPU usage

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, Buttons;

type

TForm1 = class(TForm)

Label1: TLabel;

procedure Label1Click(Sender: TObject);

procedure Label1DblClick(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

stop : boolean;

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 TForm1.Label1Click(Sender: TObject);

begin

Stop := False;

while not Stop do

begin

label1.Caption := Format('CPU speed: %f MHz', [GetCPUSpeed]);

Application.ProcessMessages;

end;

end;

procedure TForm1.Label1DblClick(Sender: TObject);

begin

Stop := True;

end;

end.

نظرات 1 + ارسال نظر
نازنین چهارشنبه 21 آذر‌ماه سال 1386 ساعت 09:54 ب.ظ

سلام من واقعا؛ نیاز فوری به کمک در مورد دلفی دارم
یه فایل پروزه ساعا دانلود کردن ولی ۴ فایل داره و یه فایل اجرای کد کل برنامرو از کجاش بیارم و یاد بگیرم؟ چرا تو سیستم دلفی خودم که هر کودمو اجرا میکنم ارور می ده

لطفا بیشتر توضیح بده اگه می تونی برام ایمیلش کن

برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد