06-16-2017 02:00 PM
06-16-2017 03:12 PM
These are all great, interesting solutions. Just curious has anyone bench marked? I do not have the time now to try.
Just some random ramblings:
Even without reverse array there should still be a buffer copy, you are branching the original string wire.
@sth - Try your solution with a conditional for loop, read that for loops are usually faster than while loops somewhere, do not know if it is still true.
Attached is another solution, inspired by the ones posted here, that tries, probably unsuccessfully, to do everything in place. may work well for long strings, but probably slower for short strings.
Cheers,
mcduff
06-16-2017 05:05 PM
@sth wrote:
Such as...
Why is your integer wire a lighter shade of blue?
06-17-2017 10:51 AM
@RavensFan wrote:
@sth wrote:
Such as...
Why is your integer wire a lighter shade of blue?
Alternate wire colors. Tools options environment. Not a default ini option.
06-17-2017 04:26 PM
06-17-2017 05:31 PM - edited 06-17-2017 05:31 PM
@JÞB wrote:
Alternate wire colors. Tools options environment. Not a default ini option.
I don't see that in Tools >> Options >> Environment dialog box. I see colors there, but nothing that relates to wire colors.
And why would anyone want to change the wire colors?
06-17-2017 06:11 PM
@drj
Not a member but I long time reader, lavag has given me a server error whenever I try to go there. Is it only open for members?
mcduff
06-17-2017 06:14 PM
@mcduff wrote:
These are all great, interesting solutions. Just curious has anyone bench marked? I do not have the time now to try.
Just some random ramblings:
Even without reverse array there should still be a buffer copy, you are branching the original string wire.
@sth - Try your solution with a conditional for loop, read that for loops are usually faster than while loops somewhere, do not know if it is still true.
@mcduff...
Just because a wire forks does not mean that the data is copied. That has changed since long long ago. The compiler delays deciding on a buffer copy until one of the forks modifies the data. In this case I just count white space and there is no need for a buffer copy. You can turn on highlighting of buffer copies to check this.
For loops were faster when the output was an array. In this case they could pre-allocate an array instead of creating an array and having to allocate more memory and copy occasionally. Since I don't have an auto-indexing output this should not be an issue.
Again, speed is not really an issue since one is usually cleaning up a command string for parsing. There are usually not 1 MB strings with 200K of white space. It can happen but that is probably not what one should optimize for. Minimizing buffer copies is probably the best optimization for the use cases. If someone wants to bench mark this, go ahead.
The problem with single threading is possibly still my issue.
06-17-2017 06:22 PM
@RavensFan wrote:
And why would anyone want to change the wire colors?
Because the garish fisher price primary colors are aesthetically equivalent to poking a fork in your eyes. I hate to start a really old flame thread, but windows users seem immune to this assault on the senses. Sort of being hit over the head lessons. It was really nice when LV moved from B&W to color but we have moved beyond the need for a 4 bit color LUT and can actually use the full capabilities of modern displays and processors to make things ergonomic and less fatiguing. As a Mac user, design matters.
06-17-2017 06:27 PM
@McDuff, two things about your design.
1. You lose the parallelism by doing both loops serially. I haven't used a single core machine since about 2000. I usually boost the threads per execution engine to 8 (the maximum allowed in the configuration VI). The beauty of LV is to be able to write parallel code in an understandable, readable, maintainable way. Forcing serialism is a "bad habit" from text based languages.
2. You may lose some speed by using shift registers which has to make the output array back to the input as it loops. Not sure about the internals of that. It may be some copies or conditionals required for this.