An interesting programming challenge
Peter Haworth
pete at lcsql.com
Fri Apr 10 13:02:40 EDT 2015
I don't think this is a fair comparison since the end results are totally
different. In the array test, the result is a large number of values
whereas in the simple variable test you end up with one value.
I changed the simple variable test to "add 23 to line i of X" so it
produces multiple values. After letting it run for a couple of minutes, I
aborted it.
Then I changed the array test to "add 23 to x[3]" so it only produced one
value. It took 2.3 seconds compared to 1.8 seconds for the variable test.
Still longer for the array but a much smaller difference, especially when
you divide it by 10000000.
Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
On Fri, Apr 10, 2015 at 9:29 AM, Geoff Canyon <gcanyon at gmail.com> wrote:
> On Fri, Apr 10, 2015 at 10:25 AM, Ben Rubinstein <benr_mc at cogapp.com>
> wrote:
>
> > making use of arrays which I always believe are insanely fast
>
>
> Arrays are much slower than simple variables.
>
> -- takes > 9 seconds:
> on mouseUp
> put the long seconds into T
> repeat with i = 1 to 10000000
> get i mod 100
> add 23 to X[i]
> end repeat
> put the long seconds - T
> end mouseUp
>
> -- takes < 1.8 seconds
> on mouseUp
> put the long seconds into T
> repeat with i = 1 to 10000000
> get i mod 100
> add 23 to X
> end repeat
> put the long seconds - T
> end mouseUp
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list