flat assembler
Message board for the users of flat assembler.

Index > Main > how to test algorithm execution speed?

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
Hi!
How can I measure the speed of program execution (in real mode)?
For example, I've coded 2 versions of one procedure and I want to see which is faster. How can I do this?
Thanks
Post 11 Jul 2006, 13:01
View user's profile Send private message Reply with quote
viki



Joined: 03 Jan 2006
Posts: 40
Location: Czestochowa, Poland
viki
With rdtsc instruction. Plase look for cpu_speed thread on this forum
Post 11 Jul 2006, 13:53
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Post 11 Jul 2006, 15:04
View user's profile Send private message Reply with quote
viki



Joined: 03 Jan 2006
Posts: 40
Location: Czestochowa, Poland
viki
zhak if you wont the same code in c for real mode, give me a sign.
Post 12 Jul 2006, 06:29
View user's profile Send private message Reply with quote
ChrisLeslie



Joined: 04 Jun 2006
Posts: 50
Location: Australia
ChrisLeslie
zhak

Timing is not very accurate in real mode as DOS "tick" counts are about 55ms in duration. However, you could try using int 1Ah to get the number of ticks since midnight before and after you run your procedures, so long as you loop your procedures a large number of times.
This piece of code before and after the looped procedure should do it.
Code:
    mov ah,00h
    int 1ah
    mov ax,cx
    shl eax,16
    mov ax,dx

    

The "ticks" since, I think, midnight ends up in EAX.
Then of course subtract the difference to find the actual duration for the looped procedure.

Chris
Post 13 Jul 2006, 03:50
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
Oh, thanks men, that helps a lot...
2 viki: IA-32 SDM says
Quote:
The RDTSC instruction is not a serializing instruction. Thus, it does not necessarily wait until
all previous instructions have been executed before reading the counter. Similarly, subsequent
instructions may begin execution before the read operation is performed.

So it means that I need to clear the command queue before executing rdtsc, isnt'it? How can I do this? With far jump... are there any other methods to do this?
Post 13 Jul 2006, 06:56
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
zhak wrote:
clear the command queue before executing rdtsc
Code:
xor eax,eax
cpuid    
Post 13 Jul 2006, 08:29
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.