Solved

TChessBrd sample progam consume 99% of CPU time

Posted on 2004-04-01
3
239 Views
Last Modified: 2010-04-16
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
Comment
Question by:soapsiam
3 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10740355
Is it the CPU useusge at its max only when the Chessboard component is doing its search for next best move?

SHane
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 125 total points
ID: 10741070

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
 
LVL 1

Expert Comment

by:FeralCTO
ID: 10742692
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question