05-28-2010 06:07 PM
I have been reading a bit in the forum and a lot of people recommended not to use sequence structures. Here is the situation: I have a tick count at the beginning for the iteration (and another at the end). I would like to force them to count before (and after) anything else. The code that I am working on let all data passing through flat sequences structures which contain tick counts only. Is there any different way that you can do it without the sequence structures?
Thans
Solved! Go to Solution.
05-28-2010 06:20 PM
Use OpenG
They have timing VI's that encapsulate Wait, Tick Count insied an error-case.
But also note that flat sequences are considered 'correct' when using tick count or wait (it's the exception where sequences are ok). So don't rewrite all your existing code, use the OpenG vi's for the newer code.
Felix
05-28-2010 06:24 PM
The recommendation not to use sequence structures applies to most of the cases where people use them. State machines are the preferred (and best) method. However, that does not mean that there is never a good use for a sequence structure. In your case, when you want to time something, it is perfectly acceptable. An example is shown in the first snippet below.
There is an alternative however. You can use a timed loop to time your code. Someone here once posted an example. I forgot who it was and which thread it was in. It went something like the second snippet.
I would like to know why there is a difference in speed between these two methods:
05-28-2010 07:36 PM
tbob wrote:[...] You can use a timed loop to time your code. Someone here once posted an example. I forgot who it was and which thread it was in. [...]
http://forums.ni.com/ni/board/message?board.id=170&message.id=501103&query.id=5008538#M501103
05-29-2010 04:16 AM
Tbob, I would guess the speed differnece is due to the wireing of the array. In the timed sequence, it is going 'nowhere', so the compiler might skip a buffer allocation.
Felix
05-29-2010 01:49 PM
tbob wrote:I would like to know why there is a difference in speed between these two methods:
06-01-2010 11:20 AM
06-01-2010 12:01 PM
altenbach wrote:
First of all, this benchmark is quite meaningless. What are you trying to measure?
- Since there is no defined execution order both structures run in parallel, and whatever can grab more CPU cycles will be faster.
- Avoid diagram constants to prevent constant folding.
- Disable debugging.
- If you want to force use of a certain CPU, try 0 instead of 1. Not everybody has multiple cores. 😉
I was not trying to benchmark anything. I just noticed the difference in execution speed and wanted to know why there was a difference. The two snippets are not in the same vi, they are separate. Sorry I didn't explain that. I'm not using these anywhere, they were just an example to show 2 methods for timing.
Perhaps Felix is right. The output array in one vi but not the other could make a difference in execution speed.