Going through an array loops is slow

138 views
Skip to first unread message

Paul [sabret00the]

unread,
Oct 9, 2012, 3:28:33 PM10/9/12
to tas...@googlegroups.com
Is there any way to throw more power behind this? Could I perhaps set Tasker to use the interactive governor before it starts the loop?

Paul [sabret00the]

unread,
Oct 9, 2012, 6:47:01 PM10/9/12
to tas...@googlegroups.com
Just to clarify, I'm doing

For %LWRWALLTMP Items %WALLS()
->Write File File; File %LWRLSTLOC; Text %LWRWALLTMP; Append On;
End For

But it's incredibly slow.

Wes Stacey

unread,
Oct 9, 2012, 6:52:30 PM10/9/12
to tas...@googlegroups.com
are you sure it's not the writing that is slowing you down and not the loop? How much data is being written?

Richard Davis

unread,
Oct 9, 2012, 6:55:54 PM10/9/12
to tas...@googlegroups.com

Try changing it to a local variable. This has made several of my loop faster.

Rich...

Paul [sabret00the]

unread,
Oct 9, 2012, 6:57:41 PM10/9/12
to tas...@googlegroups.com

~5000 lines of text

Richard Davis

unread,
Oct 9, 2012, 7:08:50 PM10/9/12
to tas...@googlegroups.com

When i tried a similar loop with far less data I was getting memory errors but setting the array to a local variable fixed it and it run much faster.

Paul [sabret00the]

unread,
Oct 9, 2012, 7:16:10 PM10/9/12
to tas...@googlegroups.com

Sorry, perhaps I'm having a stupid moment, but how do you mean?

That said, the reason I'm trying to write to a file is because I'm trying to remove an array with all the elements in. So before I clear the array, I'm attempting to write the contents to a file and save resources later by scanning the file rather than the huge directory.

Richard Davis

unread,
Oct 9, 2012, 7:44:57 PM10/9/12
to tas...@googlegroups.com


>
> For %LWRWALLTMP Items %WALLS()
> ->Write File File; File %LWRLSTLOC; Text %LWRWALLTMP; Append On;
> End For
>
> But it's incredibly slow.
>
>

I think just changing %LWRWALLTMP to %lwrwalltmp will help a lot and then if you do a
variable set %walls to %WALLS(:)
Variable split %walls with a , splitter

Then use %walls in the loop

This is what i did and it worked but as I said it was far less data..

Hope this helps...   Rich

Richard Davis

unread,
Oct 9, 2012, 7:53:12 PM10/9/12
to tas...@googlegroups.com

If you can get this loop into the same task that creates the variable %WALLS and use all local variables that would be the ideal..

Richard Davis

unread,
Oct 9, 2012, 8:37:41 PM10/9/12
to tas...@googlegroups.com

One more suggestion ....

I have found that even with local variables any loop function on a large array is slow. The next step would be to use a JavaScriptlet.  This would be faster but perhaps still to slow.

The variable split, section,set and even search and replace are very fast and after re-reading your post I think you want to archive the data but I am not sure what you mean by scan the file later.

I do not have much experience with large amounts of data and files however I would try to save the data from a comma separated variable ( or other separator) then retrieve it in the same manner and just split it again. This should be very fast...

Rich...

Richard Davis

unread,
Oct 9, 2012, 9:16:36 PM10/9/12
to tas...@googlegroups.com

OK..... I have missed the most obvious of all ( I think)   I was a little distracted before.. (that's what I get for trying to sneak in a little tasker time during FAMILY time.... ) :(    I always seem to forget about the all powerful variable JOIN...

This is untested but i believe if you just do a

Variable join of %WALLS

with a carriage return as the joiner ( I think this is possible but you might need to search the forum on how get a carriage return as a joiner) this should save to the file and give it the readability I think you are looking for.

OK that's the last one, promise .... :)

Paul [sabret00the]

unread,
Oct 10, 2012, 9:21:10 AM10/10/12
to tas...@googlegroups.com
you're right, if I do a JOIN it should be a lot quicker. I'll give it a go and let you know how it went.
--
Until Next Time, Make Me A Marvel!

Reply all
Reply to author
Forward
0 new messages