So, which one should I use? Every newbie would ask.
In terms of readability I like the FOR structure as it is the cleanest one, very easy to view. Both WHILE and DO WHILE are also great but after being rewritten as John Hotalen showed.
Another newbie's question would be: Is there any performance difference?
So I did some simple performance tests with all these traversing methods including a $Query one and working with this same ^Trans global but now populated with 50 million nodes. They all have very similar performance with exception of the FOR DO DOT syntax and $Query (uses indirection) that are much slower (~10%).
- Log in to post comments