[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

TChessBrd sample progam consume 99% of CPU time

I have downloaded a TChessBrd component from www.torry.net. After installation and running sample program I found that it uses 99% of CPU time. The question is:

     How and what methodologies should I use to check that what is the problem in this program or component?

I am running a program on WinXP SP1 and Delphi6 (all patch updated).

Thanks.
0
soapsiam
Asked:
soapsiam
1 Solution
 
shaneholmesCommented:
Is it the CPU useusge at its max only when the Chessboard component is doing its search for next best move?

SHane
0
 
Russell LibbySoftware Engineer, Advisory Commented:

No, its always pegged due to the way the component is written. (done some testing with it). A quick and dirty on this, without picking it apart

// The execution point of the thread
procedure TChessThread.Execute;
begin
    repeat
    begin
        Sleep(100); // <-- Add this to the original code
        if ((ComputerPlaysWhite^)and(WhiteToMove^))or
           ((ComputerPlaysBlack^)and(WhiteToMove^=FALSE)) then
        begin
 
------------
Regards,
Russell

0
 
FeralCTOCommented:
rllibby is right. When the Execute method of a thread loops, you gotta have a call to Sleep in it, or it will eat up the CPU.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now