1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

calculation of execution time of assembly code in a realtime program with large number of tasks

Discussion in 'Embedded' started by karthikbg, Jan 4, 2007.

  1. karthikbg

    karthikbg Guest


    I have some 20 lines of code in assembly .
    I have various tasks running. How to calculate the total time of
    execution of the code in assembly alone in Vxworks ?

    Since any task might get invoked due to various reasons ,
    Is putting one printf that prints the current time at the start of
    assmbly and another printf at the end of assmbly code that prints the
    current time the only way for caculating the assmbly code execution
    time ?

    Any other ideas.

    Thx in advans,
    Karthik Balaguru
    karthikbg, Jan 4, 2007
    1. Advertisements

  2. karthikbg

    John B Guest

    Calling 'printf()' at the start and end of 20 lines of assembler is
    meaningless. The execution time of the library code will far exceed
    that of the assembler. Use the old method of counting processor cycles
    and adding them up. You'll be surprised at how easy it is. If you don't
    have access to a pencil and paper then an abacus is quite useful.
    John B, Jan 4, 2007
    1. Advertisements

  3. karthikbg

    Arlet Guest

    I agree. To get the time for longer/more complicated pieces of code,
    you can toggle an IO pin at the beginning and end, and use a scope to
    measure the time. If the time isn't constant, a digital scope with
    infinite persistence is very handy, while trying to exercise all
    possible execution paths.

    For a software solution, make sure you have an accurate hardware timer,
    and take a timestamp at beginning and end, then subtract the values,
    and report (through printf, or any other suitable method). Use the same
    method to time an empty piece of code to measure the timestamping
    Arlet, Jan 4, 2007
  4. karthikbg

    Ignacio G.T. Guest

    Arlet escribió:
    If you use a Pentium target, you can use the internal processor's cycle
    counter, which can be accesed with a pair of protected instructions. I
    used it when debugging a subtle concurrency problem years ago, and was
    very handy.
    Ignacio G.T., Jan 4, 2007
  5. Check out the functions in VxWorks' timexLib library.
    Michael R. Kesti, Jan 5, 2007
  6. karthikbg

    werty Guest

    You dont have to if you code modular , the kernel will do it and

    run it without crash , because kernel has stats on all Primatives ,

    refuses to run a module that does not fit 110% in that slot .

    This is the essence of my Multi-tasking techniques , that never

    allow interupts , i always poll .... Just in time software !!

    See , simple .....
    I am the worlds greatest systems programmer ....
    werty, Jan 6, 2007
  7. karthikbg

    bvanevery Guest

    If the task is amenable, put the assembly code in a loop and run it
    millions of times. This makes the calculation take much longer and
    then you don't need quite so accurate a timer. Of course, you have to
    be careful that you're not changing the basic nature of the processing,
    such as reading in lotsa data from main memory that otherwise would
    have been in a cache. Anyways, "put a loop around it" is a general
    trick for benchmarking.

    Brandon Van Every
    bvanevery, Jan 7, 2007
  8. karthikbg

    karthikbg Guest

    I found something interesting w.r.t Code Composer Studio (CCS) under
    the topic of Benchmarking .
    Pls find the info below that i got from a link . (Looks interesting !!

    Code Composer Studio has the capability of benchmarking your code,
    meaning that you can analyze how long your code takes to execute. In
    the following example, you will be analyzing how long it takes to
    execute each call of the dotp() function.

    One way of benchmarking your code is to set two breakpoints. When you
    run the program, the breakpoints will tell the debugger to stop
    execution. A clock-cycle counter, built into the debugger, can be used
    to count the number of cycles between these breakpoints.

    Do DEBUG:RESTART to set the PC at the beginning of the code.

    Choose PROFILER:START NEW SESSION... with session name of your choice.

    You can profile, count the number of clock cycles, a function by adding
    it to the profile session you created. To do this, left double click on
    the lab1.c file in the Project View to view the file. Place the cursor
    on any line inside the dotp() function and right click. Choose Profile
    Fimction -> in (session-name) Session, where (session-name)
    identifies the profiling session you created.
    Execute the code by DEBUG:RUN.

    After CPU halts, click on the Functions tab of the profiling window to
    see the result of the profiling of the dotp() function.

    The numbers displayed are the statistics of the execution of the dotp()
    function gathered by CCS while executing the code.

    For interpretations of these numbers, read the CCS help topic
    Profiler:Viewing Profile Data by choosing the Help:Contents menu on the
    CCS menu bar.

    You can also add a particular line of the code to the profile session.
    Learn how to do this by reading the helps. There are lots of profiling
    capabilities that cannot be covered fully in this manual.
    How many clock cycles (on average) does it take to execute the dotp()

    Karthik Balaguru
    karthikbg, Jan 22, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.