Xojo Conferences
XDCMay2019MiamiUSA

Little Sorting Speed Challange (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Project Portability
Next thread: Student Developer Program?


Using services   -   Jan Erik Moström <
  Little Sorting Speed Challange   -   Seth Willits
   Re: Little Sorting Speed Challange   -   Will Leshner
   Re: Little Sorting Speed Challange   -   Seth Willits
   Re: Little Sorting Speed Challange   -   Norman Palardy
   Re: Little Sorting Speed Challange   -   Seth Willits
   Re: Little Sorting Speed Challange   -   Norman Palardy
   Re: Little Sorting Speed Challange   -   Seth Willits
   Re: Little Sorting Speed Challange   -   Theodore H. Smith

Little Sorting Speed Challange
Date: 29.02.04 06:45 (Sat, 28 Feb 2004 21:45:11 -0800)
From: Seth Willits
dim SortedItems(-1) as MyItem
dim iteration, x as integer

// Sorts From Newest to Oldest (0-UBound)
if Count = -1 then return
SortedItems.Append UnSortedItem.Item(0)

for iteration = 1 to Count
for x = iteration - 1 DownTo 0
if UnSortedItem(iteration).TimeAdded.TotalSeconds >=
SortedItems(x).TimeAdded.TotalSeconds then
SortedItems.Append UnSortedItem.Item(iteration)
exit
end if

if x = 0 then
SortedItems.Insert 0, UnSortedItem(iteration)
end if
next
next

Anyone wanna speed that up?

Basically, I have a collection of objects in a dictionary and I need to
perform an operation on those objects in a specific order which is
determined by comparing a TotalSeconds property in the object.


Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames

"Standing up for what you believe in is never a waste of time."
------------------------------------------------------------------------
---

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Little Sorting Speed Challange
Date: 29.02.04 06:52 (Sat, 28 Feb 2004 21:52:32 -0800)
From: Will Leshner

On Feb 28, 2004, at 9:45 PM, Seth Willits wrote:

> Basically, I have a collection of objects in a dictionary and I need
> to perform an operation on those objects in a specific order which is
> determined by comparing a TotalSeconds property in the object.
>

Have you tried Charles' SortLibrary?

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Little Sorting Speed Challange
Date: 29.02.04 08:41 (Sat, 28 Feb 2004 23:41:25 -0800)
From: Seth Willits
On Feb 28, 2004, at 9:52 PM, Will Leshner wrote:

>> Basically, I have a collection of objects in a dictionary and I need
>> to perform an operation on those objects in a specific order which is
>> determined by comparing a TotalSeconds property in the object.
>
> Have you tried Charles' SortLibrary?

I knew someone was going to say that. :)
No, I haven't tried it. I did find out that the part that takes the 6
seconds wasn't the sort. Surprisingly that little algorithm, despite
its brute-force nature, executes very very fast for what I'm doing.
Determining the size of a folder is what's taking so stinking long.

Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames

"If you can't beat your computer at chess, try kick boxing."
-- Someone
------------------------------------------------------------------------
---

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Little Sorting Speed Challange
Date: 29.02.04 09:00 (Sun, 29 Feb 2004 01:00:08 -0700)
From: Norman Palardy

On Feb 29, 2004, at 12:41 AM, Seth Willits wrote:

> On Feb 28, 2004, at 9:52 PM, Will Leshner wrote:
>
>>> Basically, I have a collection of objects in a dictionary and I need
>>> to perform an operation on those objects in a specific order which
>>> is determined by comparing a TotalSeconds property in the object.
>>
>> Have you tried Charles' SortLibrary?
>
> I knew someone was going to say that. :)
> No, I haven't tried it. I did find out that the part that takes the 6
> seconds wasn't the sort. Surprisingly that little algorithm, despite
> its brute-force nature, executes very very fast for what I'm doing.
> Determining the size of a folder is what's taking so stinking long.

How are you getting that ?
Walking all the items will take some time.

du -k in a shell might be very quick, although I'm not sure if it
includes all the resource forks of files.

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Little Sorting Speed Challange
Date: 29.02.04 09:07 (Sun, 29 Feb 2004 00:07:35 -0800)
From: Seth Willits
On Feb 29, 2004, at 12:00 AM, Norman Palardy wrote:

> How are you getting that?
> Walking all the items will take some time.
>
> du -k in a shell might be very quick, although I'm not sure if it
> includes all the resource forks of files.

I'm using:

dim sh as shell
dim path as string

if file.Directory then
sh = New Shell
path = ReplaceAll(mFolderItem.AbsolutePath, ":", "/")
path = Mid(path, InStr(path, "/") + 1)
sh.Execute "du -k -d 0 '" + path + "'"
mFileSize = Val(NthField(sh.Result, " ", 1)) * 1024
else
mFileSize = file.Length
end if

(I know that the path isn't very safe. I need to find a better way to
do that.)

I was originally using AppleScript to talk to the Finder, but that was
doooog slow and not to mention that the size is calculated
asynchronously so it wouldn't be right the first time. Using
file.Length for files is faster then asking the shell. For 67 files (14
of which are folders) it takes just under a second to calculate. Not
exactly a speed demon, but it's bearable. I cache the file size which
makes it instant from there on.



Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames

"When purchasing that gift for your Special Someone guys remember, girls
like cute things. If it makes you want to puke, your chick will totally
love it."
-- Someone else out There
------------------------------------------------------------------------
---

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Little Sorting Speed Challange
Date: 29.02.04 09:13 (Sun, 29 Feb 2004 01:13:12 -0700)
From: Norman Palardy
On Feb 29, 2004, at 1:07 AM, Seth Willits wrote:

> On Feb 29, 2004, at 12:00 AM, Norman Palardy wrote:
>
>> How are you getting that?
>> Walking all the items will take some time.
>>
>> du -k in a shell might be very quick, although I'm not sure if it
>> includes all the resource forks of files.
>
> I'm using:
>
> dim sh as shell
> dim path as string
>
> if file.Directory then
> sh = New Shell
> path = ReplaceAll(mFolderItem.AbsolutePath, ":", "/")
> path = Mid(path, InStr(path, "/") + 1)
> sh.Execute "du -k -d 0 '" + path + "'"
> mFileSize = Val(NthField(sh.Result, " ", 1)) * 1024
> else
> mFileSize = file.Length
> end if
>
> (I know that the path isn't very safe. I need to find a better way to
> do that.)
>
> I was originally using AppleScript to talk to the Finder, but that was
> doooog slow and not to mention that the size is calculated
> asynchronously so it wouldn't be right the first time. Using
> file.Length for files is faster then asking the shell. For 67 files
> (14 of which are folders) it takes just under a second to calculate.
> Not exactly a speed demon, but it's bearable. I cache the file size
> which makes it instant from there on.

probably takes a while to start the shell & run du

any way you can create 1 shell and reuse the heck out of it might speed
it up

it only takes a second or two to run DU for my whole hard drive

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Little Sorting Speed Challange
Date: 29.02.04 09:59 (Sun, 29 Feb 2004 00:59:26 -0800)
From: Seth Willits
On Feb 29, 2004, at 12:13 AM, Norman Palardy wrote:

> probably takes a while to start the shell & run du
> any way you can create 1 shell and reuse the heck out of it might
> speed it up

That's a good idea.... <tries it>

The difference was imperceptible when taking about a second overall.
I'm to lazy to *really* test it.



Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames

"Although you may often have nothing to lose, more often than not it
takes
a great deal of courage to take a chance."
-- Seth Willits
------------------------------------------------------------------------
---

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Little Sorting Speed Challange
Date: 29.02.04 14:24 (Sun, 29 Feb 2004 13:24:28 +0000)
From: Theodore H. Smith
> Basically, I have a collection of objects in a dictionary and I need to
> perform an operation on those objects in a specific order which is
> determined by comparing a TotalSeconds property in the object.

Maybe you should be using an array instead?