Solved

Execution time of assembly code

Posted on 2008-06-11
2
905 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
A Short Story about the Best File Recovery Software – Acronis True Image 2017
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

19 Experts available now in Live!

Get 1:1 Help Now