Solved

TChessBrd sample progam consume 99% of CPU time

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TVirtualStringTree  search using TEdit 7 121
Correct Component for Shopping Cart. 2 105
How to renew a Delphi rad-studio licence? 5 64
Firemonkey webbrowser scrollbars ? 1 38
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

770 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