Wouter Posted September 3, 2011 Report Share Posted September 3, 2011 (edited) VI Name: String shuffle Total VIs: 1 Description: This VI shuffles a string. Note: - Blockdiagram: Code: StrShuffle.zip What are you thoughts on this VI? Would you like to see such a function in OpenG? Can you optimize the code? In which package should it be included? Should it be rejected? Edited September 3, 2011 by Wouter Quote Link to comment
Wouter Posted October 7, 2011 Author Report Share Posted October 7, 2011 Now with http://lavag.org/topic/14873-string-to-character-array-string-package/ this can be implemented? Quote Link to comment
Darin Posted October 7, 2011 Report Share Posted October 7, 2011 (edited) The Keyed Sort is quite a slow way to perform the shuffle operation. The built-in riffle function is the fastest way. My next choice would have been the following: http://forums.ni.com...light/true#M462 Unfortunately, that creature has been returned to its cage. That leaves me with performing the good, old Fisher-Yates-Knuth shuffle, and I would probably just use the byte array instead of the char array. The section where I find a random integer between i and N-1 could certainly be replaced with the new OpenG function. Probably a modest hit in performance. The section labelled 'Knuth Shuffle' can be adapted very easily to any datatype. KnuthShuffleString.vi Edited October 7, 2011 by Darin Quote Link to comment
asbo Posted October 7, 2011 Report Share Posted October 7, 2011 Riffle. I was banging my head against my desk trying to remember that name. Here's my take on it. I benchmarked it using 1KB of Lorem Ipsum text on my Quad Core i5 and it happy chewed up 25% of each processor. But it averaged < 1ms over 250k runs. Maybe it's late on a Friday, but something seems wrong here. Edit: 70KB in 6ms. Dang. RiffleString.vi RiffleStringBenchmark.vi Quote Link to comment
Darin Posted October 10, 2011 Report Share Posted October 10, 2011 The argument against Riffle is that it is not in the base package. That is why I considered alternatives. The fastest way if you want to use Riffle.vi is to live with the coercions and Riffle the byte array from the string directly. It would be nice if NI would provide a U8 instance of Riffle.vi. (Wow, I got to say Riffle four times (now five)). Quote Link to comment
asbo Posted October 10, 2011 Report Share Posted October 10, 2011 The argument against Riffle is that it is not in the base package. That is why I considered alternatives. The fastest way if you want to use Riffle.vi is to live with the coercions and Riffle the byte array from the string directly. It would be nice if NI would provide a U8 instance of Riffle.vi. (Wow, I got to say Riffle four times (now five)). Aww, crap, you're right. What a shame. On the other hand, your implementation didn't trail by very much: KnuthShuffleStringBenchmark.vi Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.