Hi Hermann,

There's no array bug -- it's an aspect of its intentional behaviour. Appending to an element of an array always causes a copy, so you get O(N^2) complexity.

Please re-test in LiveCode 8.0.0-dp-7, because there are some large performance optimisations in that release that may affect these results. In particular, I expect anything that uses "put after" outside an array to be much faster, and anything that uses sort to be faster (if I remember correctly). This Week in LiveCode has links to the pull requests, which explain exactly what's been made faster.

                             Peter

On 13/10/2015 14:42, hh wrote:
Similar things are useful for a very specialized statistical
evaluation I have to do soon, so I tested again with LC 7:

There is an interesting difference between LC versions 6 and 7.

The 'direct way' of GC reveals now as clearly fastest.

Tested with one of GC's 12 MB strings on a Mac mini(i5 2.5 GHz),
testString() as below, and a critical value of v=500000000.
The (correct) result is 499999246, used time is in seconds.

[a] LC 6.7.7
repeat-PMB      0.326  <- fastest
repeat-GC       0.350
repeat-hh       0.445
sort-GC         0.985

[b] LC 7.1.0
repeat-PMB      3.562
repeat-GC       1.483  <- fastest, the only one with a factor < 9
repeat-hh      1163.0 <- an ARRAY BUG? :-(
sort-GC         8.156

-------------------

function testString
    set randomseed to 1444826515
    -- so you'll get exactly my test string
    repeat 1000000
       put comma & random(1000000000) after L
    end repeat
    delete byte 1 of L
    return L
end testString

function repeatPMB L,v  --[1]
   repeat for each item i in L
       if i < v then put comma & i after outL
    end repeat
    return max(outL)
end repeatPMB

function repeatGC L,v  --[2]
    put empty into R
    repeat for each item i in L
       if i < v and i > R then put i into R
    end repeat
    return R
end repeatGC

function repeathh L,v  --[3]
   repeat for each item i in L
       put comma & i after z[i < v]
    end repeat
    return max(z[true])
end repeathh

function sortGC L,v  --[4]
    sort items of L descending numeric
    sort items of L by (each >= v)
    return item 1 of L
end sortGC


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


--
Dr Peter Brett <peter.br...@livecode.com>
LiveCode Open Source Team

LiveCode on reddit: https://reddit.com/r/livecode

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to