Speed

James Hurley jhurley0305 at sbcglobal.net
Sun Aug 24 14:01:01 EDT 2014


There are significant differences in speed between 5.5 and 6.6. Not so much in deriving the permutations as in displaying the results in a field.

To see this run this in the message box:

   go url "https://dl.dropboxusercontent.com/u/47044230/PermutationSpeed3.rev”

(Does this only work in LC 6 and up?)

To see the difference in earlier vs of RR you will have to open it in 6.0 and then save it as legacy. 
The difference is significant. It takes about 3 sec to run and display the permutations (using Geoff’s code) and display them in a field in 5.0, but about 30 sec in 6.0

Almost all of that difference is in the display. It takes only about 1 sec to put the permutations into a variable.

Jim


> Mesxxxsage: 12
> Date: Sat, 23 Aug 2014 22:21:16 -0500
> From: Geoff Canyon <gcanyon at gmail.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Subject: Re: Speed
> Message-ID:
> 	<CAKCLKtpfP7OX0tju6hKPSCwyiYtO9WU07VF1eMNPru285wb5qQ at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> This has several restrictions, but it generates all permutations of 10
> items in about 6 seconds on my recent macbook. It uses two functions, one
> to generate a permuted list of single digits, and the other to replace in
> the actual items to be permuted.
> 
> The restrictions are:
> 
> 1. The general permutations function P only works with up to 10 items. It
> wouldn't be too hard to extend beyond that, but it would sully the very
> nice (IMHO) use of single digits to store the permutations.
> 2. The items to be permuted cannot contain the digits 0-9. This could also
> be worked around by using different characters for the permutation routine,
> but making it bombproof would be harder than that.
> 
> gc
> 
> 
> function P N
>   -- returns all the permutations of the digits from 0-N
>   -- only works to N = 9!!!
>   if N = 0 then return 0 & cr
>   put P(N - 1) into T
>   repeat with i = 0 to N - 1
>      put T into T2
>      replace i with N in T2
>      replace cr with i & cr in T2
>      put T2 after R
>   end repeat
>   replace cr with N & cr in T
>   return R & T
> end P
> 
> function PLines L
>   -- returns comma-delimited lines containing
>   -- all the permutations of the lines in L
>   -- The lines in L cannot contain any digits from 0 to
>   -- the number of lines - 1
>   put the number of lines of L into N
>   put P(N - 1) into R
>   repeat with i = 1 to N
>      replace i - 1 with (line i of L) & comma in R
>   end repeat
>   replace comma & cr with cr in R
>   return R
> end PLines
> 




More information about the use-livecode mailing list