Re: How to measure code execution time...?

From: Thad Smith (thadsmith_at_acm.org)
Date: 06/15/04


Date: Tue, 15 Jun 2004 08:53:03 -0600

Simp wrote:
>
> I have a pretty elementary question (I'm an intern - it happens!). My boss
> asked me to run a timer to measure how long it takes to execute some code on
> a Motorola 32-bit Microcontroller. Is there a built in tool in Metrowerks
> Codewarrior that can accomplish this? Or is there a coding technique or
> tool that I must/can use? Any help would be greatly appreciated!

I am not familiar with your specific processor and tool, but here are
three approaches:

1. Use a code simulator. Subtract the value of the cycle counter before
and after your code runs. Divide by the appropriate clock, or divided
down clock, to get the execution time on a real processor.

2. Run the code on your target system. Set a spare output high when
your code starts and low when it ends. Look at the pulse on a scope or
measure with an external timer.

3. Use an internal timer with suitable range and resolution to measure
the execution time. Read it before and after the code, then subtract.
Multiply by the time per tick.

Thad



Relevant Pages

  • Re: Time ./a.out equivalent in Windows
    ... clock will be the same, and thus the difference will always be ... Maybe something to with Windows, and the OP wanted this on Windows. ... I see that you're measuring elapsed time, rather than execution time, ...
    (comp.lang.c)
  • Re: Time ./a.out equivalent in Windows
    ... both the return values from clock ... clockshould give the execution time of the ... Maybe something to with Windows, and the OP wanted this on Windows. ...
    (comp.lang.c)
  • Re: Ada.Execution_Time
    ... probably could find a use for in a hard real-time system. ... execution time of a task" nor the usefulness of Ada.Execution_Time and its ... They only mean that the measured execution time of one ... and variability of execution-time measurements. ...
    (comp.lang.ada)
  • Re: COBOLs Influence on C
    ... Robert's reply seems to "assume" an IBM mainframe environment. ... learn of missing external names either at link or execution time. ... compilation and before execution. ...
    (comp.lang.cobol)
  • Re: Debugging Challenge - no source available
    ... > custom controls. ... > few bitmap operations which use a timer to help time-slice so the UI ... > - the debugger stops at the Application.Runline, there's no call stack, ... > In both cases, the debugger catches execution at the same point, just ...
    (microsoft.public.dotnet.general)