How to measure execution time for a portion of VxWorks code using VxWorks 5.5 and Tornado 2



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2006/12/how-to-measure-execution-time-for/

You should be redirected in 2 seconds.



Use sysTimestamp() as documented in "VxWorks Device Driver Developer's Guide 6.2". This is the library used to measure time in WindView. If not already included, you need to include the system-defined timestamping in the VxWorks kernel. From the VxWorks tab of your bootable project in Tornado go to: "development tool components" -> "Windview components" -> "select timestamping" Right click on "system-defined timestamping" and choose "include 'system-defined timestamping'...", click "OK" Use sysTimestamp as shown in the example below:
void my_task()
{
    UINT32 timestamp1, timestamp2;
    double tsperiod, delta_time;

    sysTimestampEnable();
    tsperiod = (double)sysTimestampPeriod();

    timestamp1 = sysTimestamp();

    /* execute some code */

    timestamp2 = sysTimestamp();
    delta_time = (double)(timestamp2 - timestamp1)/tsperiod/sysClkRateGet();

    exit(0);    
}
Technorati tags:

1 comment:

Bruce Cran said...

sysTimestampPeriod returns the number of ticks the timer counts before resetting - I think sysTimestampFreq should be used to get the frequency in ticks per second in order to calculate the delta time.

About

This is my *OLD* blog. I've copied all of my posts and comments over to my NEW blog at:

http://www.saltycrane.com/blog/.

Please go there for my updated posts. I will leave this blog up for a short time, but eventually plan to delete it. Thanks for reading.