Solved

Execution time of assembly code

Posted on 2008-06-11
2
908 Views
Last Modified: 2012-06-22
Hi,
for some reason I need the time a piece of assembly code should need.
In the good old 8086 time the Intel Manual told how much time a single instruction need.

I have tried to read the Intel documentation to find the timing for the instructions of the instruction set But I was not able to find it.
Could someone can tell me how I can determine the time a pice of code should use?

Here is the code I want the timing for.
      mov      DWORD PTR _k$[ebp], 1000000            ; 000f4240H
      jmp      SHORT CheckCondition
Next:
      mov      eax, DWORD PTR _k$[ebp]
      sub      eax, 1
      mov      DWORD PTR _k$[ebp], eax
CheckCondition:
      cmp      DWORD PTR _k$[ebp], 0
      jle      SHORT LoopEnd
      jmp      SHORT Next
LoopEnd:

But I need an instruction How the timing can be calculated.
It is machine dependent and must run on different Intel CPU's

Thanks for the Help

Regards
Norbert
0
Comment
Question by:Norbert
2 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 21767262
>> Could someone can tell me how I can determine the time a pice of code should use?

That is VERY complicated, if not impossible, since today's CPU's have a lot of performance optimizations in them (pipelines, superscalar CPU's, instruction caches, branch prediction, speculative execution, out-of-order execution, etc.), so the timing will highly depend on the CPU, but also on the current state of the CPU (ie. based on the instructions before and after the instruction to be measured).


If you are just looking for the instruction execution latencies, you can find those in the technical documents. For example, for the AMD64 processors, you have these documents :

    "Software Optimization Guide for AMD64 Processors" (http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25112.PDF) -> appendix C lists the instruction latencies

    "AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions" (http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24594.pdf) -> gives more detailed information about the instructions

I gave that CPU as an example, because that's the one I'm using ;) Similar documents can be found for other CPU's, and I'm sure Intel also has these kind of documents with this information.
0
 
LVL 3

Author Comment

by:Norbert
ID: 21814013
The good old times are gone. so it is no more possible to determine exact what time is theoretical used for a code sequence. But you gave me some hints where I can look and I Found also some answers

Thanks
Regards
Norbert
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now