Hello,

i have a strange question:

What commands slows down a program?

I mean something like:

mov eax, 0 instead of xor eax, eax or movzx...


Is there a list of something like that?

What else can slow down an app?

If this question is too strange, then please ignore it... ;)


DKT
Posted on 2004-01-19 09:03:27 by Kreatief
div and loop all i know, if you got some app run slow then try:


.elseif uMsg == WM_CREATE
invoke GetCurrentProcess
invoke SetPriorityClass,eax,REALTIME_PRIORITY_CLASS

invoke GetCurrentThread
invoke SetThreadPriority,eax,THREAD_PRIORITY_TIME_CRITICAL
invoke Sleep,0
invoke SwitchToThread
Posted on 2004-01-19 09:15:17 by zabnik
Try updated optimization manual from http://www.agner.org/assem/ , file pentopt.pdf
Posted on 2004-01-19 13:10:43 by MazeGen
Delay:

push ecx
mov ecx,0ffh
push ecx
mov ecx,0ffffh
loop $-00h
pop ecx
loop $-09h
pop ecx
ret


bla
bla
call Delay
bla
bla
Posted on 2004-01-19 13:56:01 by mrgone
Never use a delay loop like that - if you *want* to slow down your app, use Sleep() or whatevery our OS provides. If you want to avoid slow code, indeed get agner fog's optimization manual, plus the intel and AMD optimization guides.
Posted on 2004-01-19 14:20:06 by f0dder
to create a delay use the pc timer, read the time, w8 1 sec..etc and return.
Posted on 2004-01-19 14:32:11 by wizzra
I repeat: to create a delay, use Sleep() or whatever your OS supports. This will make sure your thread doesn't take up valuable CPU processing power while it's waiting.
Posted on 2004-01-19 14:45:41 by f0dder
Fodder, Sleep() Stink!
Posted on 2004-01-19 16:16:37 by wizzra
Erm, say what?

Sleep() has sufficient accuracy for most simple stuff - around 25ms by default, I think. Besides, this accuracy can be boosted.
Second, Sleep() makes sure your thread isn't scheduled until the wait period is over, and save you from the CPU overhead of constantly polling a timer. You should generally avoid *any* form of polling, and rather use functions such as Sleep and WaitFor*Object* - also the case of waiting for child process termination, don't loop GetExitCodeProcess, rather do a WaitForSingleObject on pi.hProcess (and be sure to CloseHandle the hProcess and hThread to avoid kernel-mode object leak, which rather quickly becomes devastating on win9x).
Posted on 2004-01-19 16:22:36 by f0dder
Plus any the delay loop written by mrgone will suit one processor speed only...
If you'd written the delay loop for the 486 and then ran on a 3.2 GHz P4 the loop won't be enough.
Statically coded decrementing loops are a bad idea.

Mirno
Posted on 2004-01-19 17:23:18 by Mirno

Plus any the delay loop written by mrgone will suit one processor speed only...
If you'd written the delay loop for the 486 and then ran on a 3.2 GHz P4 the loop won't be enough.
Statically coded decrementing loops are a bad idea.

Mirno


-- Totally off topic: :)

That's an old school (bad) programming practice...
In fact most programs made in Turbo Pascal don't work anymore on today's computers because they used a loop like that in the initialization code to estimate the CPU speed.

The idea was to read the timer value, loop a while, read the timer again and substract to get the time taken to run the loop. That number was used later for further calculation. The problem? In a fast CPU, the loop would take 0 ms to run :grin: (not really, but faster than the clock anyway) causing a division by zero later (runtime error 500)... :sweat:
Posted on 2004-01-19 17:34:27 by QvasiModo
Hrm, I thought it was runtime error 200 - and I've fixed it in a number of binarie ^_^
Posted on 2004-01-19 17:38:28 by f0dder
:grin:
Uhm... wait... lemme check... "Runtime error 200"... D'oh! :o
Posted on 2004-01-19 18:26:57 by QvasiModo

(...) and I've fixed it in a number of binarie ^_^

A crude solution (one of my first ASM projects) :)
Posted on 2004-01-19 18:29:02 by QvasiModo