CPU usage

Got a problem with TTDPatch? Get help here.

Moderator: TTDPatch Moderators

Post Reply
SHADOW-XIII
Tycoon
Tycoon
Posts: 14275
Joined: 09 Jan 2003 08:37

CPU usage

Post by SHADOW-XIII »

I remember there was some additions in TTDPatch that free CPU usage when game is paused ...
however it does work with wo faster speeds but it does not work on the fastest one (cpu usage is 100% when paused)
what are you looking at? it's a signature!
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

This is because of the way gamespeed works: it decreases the amount of time that TTD waits between two gameticks. The fastest setting means "as fast as your computer can do it", i.e. no delay at all.

The old TTD code used an infinite loop to wait that time to pass. The new code uses the Windows function Sleep() instead, so Windows can do other tasks while TTD is waiting. If there's no delay at all, however, the new method can't do anything to release CPU time, so you end up with 100% CPU usage.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
SHADOW-XIII
Tycoon
Tycoon
Posts: 14275
Joined: 09 Jan 2003 08:37

Post by SHADOW-XIII »

so maybe possibility to:
invisible change to normal speed when game is paused (so that it won't use 100% CPU)
and after unpausing it becomes the same speed it was before
what are you looking at? it's a signature!
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman »

Well, there are reasons to leave it at a higher speed even when paused, for example you get smoother scrolling and faster updates of the window system. If you need to use your CPU for something else while paused, just hit the 'W' key ;)
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
Rob
Tycoon
Tycoon
Posts: 4355
Joined: 31 Dec 2002 16:52
Location: Ven-Zelderheide, The Netherlands

Post by Rob »

There is another problem with the speedsetting : it isn't saved with the game.
The game always starts up with normal speed.
Could this be changed?
Wie zich gelukkig voelt met het geluk van anderen, bezit een rijkdom zonder grenzen. (F.Daels)
Image
Still the best OS around
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman »

It could be, but I'm not sure it's appropriate. The game speed is really a property of the game engine or the computer, rather than the savegame.

Maybe it would be better to allow a parameter to the gamespeed switch that sets the initial speed instead.
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
Rob
Tycoon
Tycoon
Posts: 4355
Joined: 31 Dec 2002 16:52
Location: Ven-Zelderheide, The Netherlands

Post by Rob »

That would be nice, yes. :D
My game is rather slow, :roll: and trains run somewhat jerky.
I have to hit the Q-key twice, to get them moving smooth again, so I am in favor of the parameter.
Wie zich gelukkig voelt met het geluk van anderen, bezit een rijkdom zonder grenzen. (F.Daels)
Image
Still the best OS around
SHADOW-XIII
Tycoon
Tycoon
Posts: 14275
Joined: 09 Jan 2003 08:37

Post by SHADOW-XIII »

relating to the 100% CPU .. TTD is said to use max CPU as it can at fastest game speed ... maybe doing max_CPU-1 should fix that :wink:
what are you looking at? it's a signature!
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

I don't see how this would be better. If you don't use all the CPU time, it isn't the fastest possible setting, is it? Let's say we put the minimal amount of sleep (1 millisecond) between ticks. Now, depending on the speed of your CPU, the CPU load drops and the game slows down accordingly.

I've experienced with this a bit on my machine:

Code: Select all

With 1 ms sleep between ticks
    CPU usage: 10-20%
    Time to simulate one year: 2:21
With no sleep between ticks
    CPU usage: 100%
    Time to simulate one year: 1:50
As you can see, this minimal delay would slow down the simulation so it wouldn't be the fastest anymore.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
Post Reply

Return to “Problems with TTDPatch”

Who is online

Users browsing this forum: No registered users and 15 guests