Formatting parameter for combine and split
Moderator: Klaus
Formatting parameter for combine and split
..........
Last edited by [-hh] on Wed Aug 13, 2014 12:21 pm, edited 1 time in total.
shiftLock happens
Re: Formatting parameter for combine and split
Hi HH,
And if you use "repeat for each" you get a really fast handler.
I did a test with a list of 100,000 lines (oneHundredThousand)
a line consisted of 20 random words of five chars each then a tab and a number. see example below.
---------------------
fxezr fxezr fxezr fxezr ugbiq ugbiq fxezr fxezr fxezr ugbiq ugbiq fxezr ugbiq fxezr fxezr ugbiq ugbiq ugbiq fxezr fxezr 4
-------------------------
pretty much what you would get from a combine when looking for duplicate lines.
I used this code
It took 390 milliseconds to rearrange the list -> number first then a tab and then the 20 words (MacBook Pro core i5 2.53 GHz)
That is not too shabby and I don't know if this necessitates additional syntax for combine.
Kind regards
Bernd
Livecode is really quite fast at rearranging lists if you do it right. Livecode is fastest if you append to a variable but gets really slow if you prepend (put before) a variable.combine <A> will respect a param or global 'valueBeforeKey' that makes (value,key) the output order for each element of <A> with a onedimensional array <A>
And if you use "repeat for each" you get a really fast handler.
I did a test with a list of 100,000 lines (oneHundredThousand)
a line consisted of 20 random words of five chars each then a tab and a number. see example below.
---------------------
fxezr fxezr fxezr fxezr ugbiq ugbiq fxezr fxezr fxezr ugbiq ugbiq fxezr ugbiq fxezr fxezr ugbiq ugbiq ugbiq fxezr fxezr 4
-------------------------
pretty much what you would get from a combine when looking for duplicate lines.
I used this code
Code: Select all
on mouseUp
put field "result" into tData
put the milliseconds into tStart
set the itemDelimiter to tab
repeat for each line aLine in tData
put item 2 of aLine & tab & item 1 of aLine & cr after tCollect
end repeat
delete last char of tCollect
put the milliseconds - tStart into field "computationTime"
put tCollect into field "result"
end mouseUp
That is not too shabby and I don't know if this necessitates additional syntax for combine.
Kind regards
Bernd
Re: Formatting parameter for combine and split
..........
Last edited by [-hh] on Wed Aug 13, 2014 12:21 pm, edited 1 time in total.
shiftLock happens
Re: Formatting parameter for combine and split
Hi HH
I agree with you that combine is faster, and your feature request will give even faster results in special situations
My point is that in special situations like you describe the performance hit is small using repeat.
If you generate the list that combine gives you by reading out the array withyou can at the same time do your formatting for the resulting list.
in the case of an array with 100,000 keys/values combine takes about 280 milliseconds. Above technique 380 to 410 milliseconds
So the overhead of doing "repeat" is about 130 milliseconds.
or in the case of your stack "counted sets part 1" with 624 distinct lines combine takes about 680 - 700 MIKROseconds and above technique about 950 - 1000 MIKROseconds. (measuring in Microseconds = the long seconds, is not very precise)
The same probably applies to split.
Kind regards
Bernd
I agree with you that combine is faster, and your feature request will give even faster results in special situations
My point is that in special situations like you describe the performance hit is small using repeat.
If you generate the list that combine gives you by reading out the array with
Code: Select all
repeat for each key aKey in tArray
in the case of an array with 100,000 keys/values combine takes about 280 milliseconds. Above technique 380 to 410 milliseconds
So the overhead of doing "repeat" is about 130 milliseconds.
or in the case of your stack "counted sets part 1" with 624 distinct lines combine takes about 680 - 700 MIKROseconds and above technique about 950 - 1000 MIKROseconds. (measuring in Microseconds = the long seconds, is not very precise)
The same probably applies to split.
Kind regards
Bernd
Re: Formatting parameter for combine and split
..........
Last edited by [-hh] on Wed Aug 13, 2014 12:21 pm, edited 1 time in total.
shiftLock happens
Re: Formatting parameter for combine and split
Hi HH,
glad you liked it. And you put it to perfect use in your new versions of Counted Set stacks.
That was the whole point: "repeat for each" allows for speed almost as if the engine provides a certain output format for arrays but "repeat for each" is much more flexible.
Kind regards
Bernd
glad you liked it. And you put it to perfect use in your new versions of Counted Set stacks.
That was the whole point: "repeat for each" allows for speed almost as if the engine provides a certain output format for arrays but "repeat for each" is much more flexible.
Kind regards
Bernd