Re: Timing your loops
- From: "Daniel" <DanielV@xxxxxxxxxxxxxxxx>
- Date: Fri, 19 May 2006 17:44:39 +0100
Hi Richard
My apologies too then for taking it personally.
That does help, i tried the 0 parameter but i found it shot to 100% again. I
am still unsure what the best way is to measure cpu usage tho since you say
taskmanager isnt accurate.
I think i get your meaning tho, since my thread is in an infinite rendering
loops it updates every iteration causing cpu usage. So would sticking a
timer of x ms between each loop be an acceptable way to slow it down?
And yes i do need multiple separate windows. Theoretically i could do it in
a manner that keeps every window inside of a split frame which is one
approach but each window will literally be a separate instance of the game.
It innvolves having multple tables where players play and as such to be on
two tables at once a new instance of the game needs to be created and
handled separate to the first.
However all this said if letting the app suck 100% isn't actually a bad
thing then maybe i will leave it as it is.
Thank you for your help.
"Richard Fine [DXMVP]" <rfine@xxxxxxxx> wrote in message
news:uuUsDg1eGHA.4948@xxxxxxxxxxxxxxxxxxxxxxx
Sleep permits 0 as a parameter. Second sentence describing that parameter
in MSDN: "Specify zero (0) to indicate that this thread should be
suspended to allow other waiting threads to execute."
Anyway, my apologies to you. It's just that I see people doing this so
very, very, very often, and every once in a while I just get fed up. It
was more of an "aargh, another one has fallen into the trap!" and not a
"you idiot, how could you do something so stupid!"
What you could do is try switching your app from an active to a passive
paradigm. Instead of taking a 'greedy' approach that uses up as much CPU
time as possible unless you remember to stop it, have you considered an
approach whereby you generally do nothing, but occasionally you'll render
a frame? Set up a Timer object to fire off every 30ms or so, and when it
fires, render&present. Providing your timer-handling code takes less than
30ms to execute, your app should go back to sleep between frames.
I'm not much of a .NET person yet, so yes, I don't really know the best
answer to your question. I wasn't sure whether to try and hazard a guess
at the things I only half know about and potentially mislead you, or to
stick to the things I /do/ know about (like CPU percentages), but you've
managed to persuade me to answer as best I can with my limited knowledge.
Andy Dunn (the ZMan) is probably the best person to ask for an
authoritative answer.
Regarding your second original question: there should be no issues with
it, beyond the simple fact that rendering four windows will mean four
render passes and presents. If this is for a 3D editor or something,
consider faking the four windows by using one D3D window and drawing your
own splitter bar over the top of it.
- Richard
P.S. If you expect newsgroups to be 'naturally' kind and helpful, you must
be fairly new to the net... many of them are famous for the levels of
vitriol and venom bandied about within :-)
Daniel wrote:
Aside from being patronising and rude with the caps you have not answered
my question regarding using sleep, also regarding the best way to run my
render loop.
i have seen other apps that i am trying to emulate and while running
their cpu power is 2% usage in task manager. I want the same. As they can
achieve this i CAN use this as a measurement since my app should do the
same. By your reckoning why dont all apps that are presently running use
100%? After all they are running and while doing nothing are allocated
all the cpu power left....mustn't be left for a rainy day after all. When
i sleep my thread i get my cpu power to 0-1% but i want it slightly
higher but i cant sleep by 0.5 as it requires an int. I know there must
be a better way such as rendering at 33fps and int he extra time saves
leaving the cpu alone thus dropping the %. To test it via opening one app
and another and seeing is there any slow down? no ..good, ok next two
apps is to be honest rediculous. I would have appreciated my question
answered not sarcastic remarks. I only presume you don't know how to
answer the question in which case a simple 'the taskmanager is not best
to guage cpu power, try this way' etc etc.
I appreciate that you did take time to answer but besides making me feel
stupid you have not helped, not really the nature of a newsgroup i feel.
"Richard Fine [DXMVP]" <rfine@xxxxxxxx> wrote in message
news:%235xJBxmeGHA.536@xxxxxxxxxxxxxxxxxxxxxxx
DON'T USE THE TASK MANAGER CPU PERCENTAGE TO GAUGE THE CPU POWER YOU'RE
USING!
If you want to target, say, 50% CPU usage, what exactly do you expect
the system to do with the remaining 50%? Keep it in a box for a rainy
day? :-)
CPU percentages are /only/ useful (and even then, not /very/ useful) for
comparing the CPU timeslice assignment of two active apps running
simultaneously. They are /not/ useful for gaining any kind of absolute
measure of the power you're using. If nothing else is going on on the
system, Windows will automatically assign as much CPU time to your app
as it has spare. 100% of the CPU doesn't mean that your app is
/demanding/ that much attention, it just means that the scheduler is
/giving it/ that much attention.
If you want to test this kind of thing, decide upon your target load in
terms of applications (e.g. you want to be able to run Word and Doom3
while your app is open with no noticable slowdown) and test it that way.
- Richard
Daniel wrote:
While windowed it uses 100% cpu power which i dont mind and by using
application.doevents it doesnt lock out the system. However i would
rather it not use so much cpu power on client machines.
.
- Follow-Ups:
- Re: Timing your loops
- From: Richard Fine [DXMVP]
- Re: Timing your loops
- References:
- Timing your loops
- From: Daniel
- Re: Timing your loops
- From: Richard Fine [DXMVP]
- Re: Timing your loops
- From: Daniel
- Re: Timing your loops
- From: Richard Fine [DXMVP]
- Timing your loops
- Prev by Date: Re: Silent Install issue
- Next by Date: Re: Timing your loops
- Previous by thread: Re: Timing your loops
- Next by thread: Re: Timing your loops
- Index(es):
Relevant Pages
|
Loading