I want to know how to determine elapsed time of few instructions in 1 ms
resolution.
I tried to use tickGet() to get the system tick count (in my case , the
resolution is 5ms),
Is there a way to measure the elapsed time in 1ms resolution ?
Thanks for your help!
Use a high resolution timer; this is fairly hardware dependant, but certainly
all 586, 686 and PowerPC processors have an internal high resolution timer.
Other boards might use an external timers. You'll need to look at your BSPs
documentation.
FWIW i get <40ms resolution on my 8245 target (PowerPC).
Usually the API calls to architecture specific timers aren't terribly well
documented, so using WindView is probably easier - all you need to do is
place a wvEvent() call either side of code you want to measure.
[snip]
Check if a timestamp driver is provided with your BSP. Resolution of a
timestamp driver is below ms and it is hardware dependant. Generally it is
integrated with the system timer driver.
If yes, you will have following functions:
sysTimestampFreq() - get the timestamp timer clock frequency (in ticks per
second)
sysTimestampPeriod() - get the timestamp timer period
sysTimestamp() - get the timestamp tick count
...
If no, you can write your own timestamp driver who use a high timer of your
board (if enable).
Refer to Appendix G "Creating a VxWorks Timestamp Driver" of the WindView
User's Guide.
HTH,
Patrick
The high resolution timers are certainly the best way to go (look for
a timestamp driver: add INCLUDE_TIMESTAMP to your kernel, and then you
can use the routines prefixed sysTimestamp, for example,
sysTimestampGet() - check in target/h/drv/timer/timerDev.h for more
info).
Failing that, since you are only after 1ms resolution, you could try
increasing the standard system clock rate to 1000. That should not be
too great a load for modern CPUs (the load comes from the fact that
the kernel will be called for each clock tick, so now you'll be
executing the kernel's tick management code 1000 times a second as
opposed to the default - normally 60 times a second). You can change
this using sysClkRateSet(). Remember that any timeouts or taskDelay()
calls will need to take into account the change in rate (or be written
using sysClkRateGet() to determine the current rate each time).
Finally, there is a library called timexLib that is there for the
purpose of timing routines. As long as your code can be called many
times without problems, you could take a look at timex() or timexN()
to measure the time you are after.
HTH,
John...
molochai <molo...@vapour-trail.demon.co.uk> wrote in message news:<57ee1ec54a%molo...@vapour-trail.demon.co.uk>...