This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do I calculate the execution time for a program?

Hello,

I use a LPC2148(arm7) in uVision Keil Mdk. I get the dis-assembly listing when I compile any code.Suppose if I want to calculate the execution time for the code, one way is to find the number of cycles for execution each instruction,multiply it with the clock frequency,have a recursive addition for all the instructions and finally I can get it.. But I don want to do it manually. I want to develop an app where if I enter the dis-assembly listing and the clock frequency used, it must give me my execution time. we have the readily available dis-assembly listing for the respective code generated from the ide. But how do I proceed with that? I hope I am clear with my question..

Regards
Ram Prasadh

Parents Reply Children
  • The main think you missed here is that for an individual instruction, you could try to look up the cycle count.

    But a real program isn't a single linear sequence of instructions. It branches and loops. And some instructions takes different time depending on input data.

    Not only that. But think about a trivial memory read. It will matter if you read from flash (and in the case the flash happens to be cached in a cache line) or from RAM. And it will matter if the address corresponds with some I/O functionality. And if doing load/store, you may need to keep track of how many outstanding stores the memory controller or the I/O controller hardware can keep track of before being forced to stall the processor core to avoid overflowing.

    That is a reason that high-end processors often have internal performance counters, allowing a test program to run and then read out the performance counters to figure out
    - number of clock cycles consumed
    - number of read stalls
    - number of write stalls
    - ...

    It is almost impossible to simulate this perfectly, because you basically have to simulate the gated logic inside the processor. Keil staff neither have the capacity or the information needed to do this kind of simulation perfectly. So a single end user who haven't spent years jumping in and out of processor cores, simulators, ... will not have an easier time to perform this task.

  • Damn - why do I so often manage to write "think" when trying to write "thing"? Must be damaged synapses somewhere...