Returns in a column

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: Returns in a column

Post by GregWills » Mon Jul 29, 2019 7:57 am

The above script is faster with small amounts of data, but dramatically slows down as the number of items increase.

10,000 items - 1 second (Speeds were timed with a stopwatch so are only a guide.)
20,000 items - 2 seconds
40,000 items - 4 seconds
80,000 items - 14 seconds
160,000 items - 50 seconds

I would have thought that doubling the number of items would only double the time taken.

Any thoughts?

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Returns in a column

Post by bogs » Mon Jul 29, 2019 9:32 am

GregWills wrote:
Mon Jul 29, 2019 7:57 am
(Speeds were timed with a stopwatch so are only a guide.)
Heh, it was too much trouble to get the seconds before and after the routine and subtract them?

Code: Select all

#line before code your testing....
put the seconds into tStartTest

// your code to do whatever...

put the seconds into tStopTest; answer (tStopTest - tStartTest)

// your code contines...
Image

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Returns in a column

Post by jameshale » Tue Jul 30, 2019 2:16 am

Moving along a list/string for the n’th item gets progressively longer as the count needs to start at the beginning of the list/string EACH time.
Where I have had to do this I have found using three variable solution.
<pseudo code>
Put you data into X
Put “” into Z
Repeat until X is empty
Put item 1 to 15 of X into Y
Replace return with “—“ in Y —don’t have char you used
Put Y & return after Z
Delete item 1 to 15 of X
End repeat
<end pseudo>

Oh, also add @bogs timer😏

GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: Returns in a column

Post by GregWills » Tue Jul 30, 2019 7:32 am

Thanks bogs for the timer. It greatly aided my sanity today :-)

I had a mixed bag of times from this morning to this afternoon? But definitely with smaller numbers of items, times were reasonable. Large numbers of items (160,000) had ridiculous times.

Thanks jameshale for your insight. That makes sense to me now, as the times looked exponentially larger as the number of items increased. I will explore your script tomorrow with fresh eyes. If times are reasonable, then the rest will be easy. Adding data to this item is breeze with the delimiter set to “¤” (of course I found a rogue “;” or two hidden amongst the text!!) and converting the "¬" back to a return takes no time at all.

I’ll report back on how it goes.

Cheers

Greg

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Returns in a column

Post by bogs » Tue Jul 30, 2019 11:33 am

jameshale wrote:
Tue Jul 30, 2019 2:16 am
Moving along a list/string for the n’th item gets progressively longer as the count needs to start at the beginning of the list/string EACH time.
I don't use offsets much for what I do work on, but unless my understanding of them is completely off (which it may be), wouldn't this be an ideal use for one?

Something in the repeat loop like (completely off the top of my head)...

put line (the line your loop is at) into tmpOffset
put line tmpOffset to line -1 of (the text) into txtRemaining
{do whatever your doing with the text}...

or
put line (the line your loop is at) into tmpOffset
{do whatever your doing with the text} line tmpOffset to -1 of {your container}

I haven't woken up all the way yet, so take the above with a gallon of coffee Image
Image

GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: Returns in a column

Post by GregWills » Wed Jul 31, 2019 8:29 am

Thanks jameshale, that did the trick.

Processing 177,631 items was completed in 28 seconds. Nice. I can live with that. :-)

I ended up changing the itemdelimiter to “~”, as OpenOffice needed the itemdelimiter to be nominated each time the resulting exported .csv file was opened (not sure why, as it doesn’t with the ~). (A “¤” therefore wasn’t going to work for different office staff.) With a bit of tweaking of the script and I’m back in business.

Many thanks to everyone who chipped in to help. Always great to be guided by this supportive group and learn heaps along the way.

Cheers

Greg

Post Reply

Return to “Databases”