Solved

TChessBrd sample progam consume 99% of CPU time

Posted on 2004-04-01
3
237 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

896 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now