Real Software Forums
http://forums.realsoftware.com/

Folderitems and Realstudio 2011 R 4 slowdown
http://forums.realsoftware.com/viewtopic.php?f=7&t=42126
Page 1 of 1

Author:  thomas [ Sat Jan 07, 2012 1:16 pm ]
Post subject:  Folderitems and Realstudio 2011 R 4 slowdown

Hi , i have a Problem with 2011 R4 . I have written a routine, which recursivly retrieves all files on a harddisc or in x folders. Everything works fine with Realstudio before R4 ... After i changed my environment to R4 - the Routine significally slows down . I tracked it down to folderitem.trueitem which IS 40% slower as in R3. You do not recognize this if you only have 300 or 500 Files / Folders , but it bring's me into trouble if my clients retrieve about 40000 files on a drive.
Anybody experienced the same problem ? Any solutions ?
THX
Thomas

Software runs on MacOS Lion and SnowLeopard ( Same Speed Problem )

Author:  sinner [ Sat Jan 07, 2012 1:32 pm ]
Post subject:  Re: Folderitems and Realstudio 2011 R 4 slowdown

thomas wrote:
Hi , i have a Problem with 2011 R4 . I have written a routine, which recursivly retrieves all files on a harddisc or in x folders. Everything works fine with Realstudio before R4 ... After i changed my environment to R4 - the Routine significally slows down . I tracked it down to folderitem.trueitem which IS 40% slower as in R3. You do not recognize this if you only have 300 or 500 Files / Folders , but it bring's me into trouble if my clients retrieve about 40000 files on a drive.
Anybody experienced the same problem ? Any solutions ?
THX
Thomas

Software runs on MacOS Lion and SnowLeopard ( Same Speed Problem )


Try using windows declares works faster then built in window search.

Soft Declare Function FindFirstFileW Lib "Kernel32" ( path as WString, data as Ptr ) as Integer
Soft Declare Function FindNextFileW Lib "Kernel32" ( handle as Integer, data as Ptr ) as Boolean
Declare Sub FindClose Lib "Kernel32" ( handle As Integer )

Author:  thomas [ Sat Jan 07, 2012 2:11 pm ]
Post subject:  Re: Folderitems and Realstudio 2011 R 4 slowdown

I do not need a search function nor runs The software on Windows . I have to retrieve every filename on SAN systems with MacOSX clients attached. No need to search for a special filepattern or something like that. But THX for the answer

Author:  sinner [ Sat Jan 07, 2012 2:27 pm ]
Post subject:  Re: Folderitems and Realstudio 2011 R 4 slowdown

something like this?

Function FilePattern(f as folderitem) as boolean
dim s(),n as string
s = Array("jpg","txt","xml")
n=f.name
if instr(n,".")=0 then
return false
else
return( s.indexof( NthField(n ,".",CountFields(n,".") ) ) > -1 )
end
end

Author:  npalardy [ Sat Jan 07, 2012 3:05 pm ]
Post subject:  Re: Folderitems and Realstudio 2011 R 4 slowdown

thomas wrote:
Hi , i have a Problem with 2011 R4 . I have written a routine, which recursivly retrieves all files on a harddisc or in x folders. Everything works fine with Realstudio before R4 ... After i changed my environment to R4 - the Routine significally slows down . I tracked it down to folderitem.trueitem which IS 40% slower as in R3. You do not recognize this if you only have 300 or 500 Files / Folders , but it bring's me into trouble if my clients retrieve about 40000 files on a drive.
Anybody experienced the same problem ? Any solutions ?
THX
Thomas

Software runs on MacOS Lion and SnowLeopard ( Same Speed Problem )


Really depend on how you iterate over your folder items
If you do
for i as integer = folder.Count downto 1
process( folder.item(i) )
next

you will find this IS much slower

If you do
for i as integer = 1 to folder.Count
process( folder.item(i) )
next

you'll be much quicker
This is a result of a change to use the newer API's in OS X that make iterating forwards MUCH faster than backwards

Author:  thomas [ Sat Jan 07, 2012 4:33 pm ]
Post subject:  Re: Folderitems and Realstudio 2011 R 4 slowdown

Hi Norman ,
Yes! This is it! I count down after i changed my code to iterate up it IS much faster.
THX Thomas

Author:  thomas [ Sun Jan 08, 2012 9:32 am ]
Post subject:  Re: Folderitems and Realstudio 2011 R 4 slowdown

After i checked it all in a real environment - Things slow down again.


dim count as Integer = folder.Count
dim fx as folderitem

for i as Integer = 1 to count

if folder.trueItem( i ) <> nil then

fx = folder.trueItem( i )

// directory or not
if fx.Directory then
GetFilesinFolderA( fx, farray)
end if

// process - if it is not a system thing
if fx.name <> "" and left(fx.name,1) <> "." then
if not fx.Directory then
farray.Append fx
end if
end if


end if

next i


The name of the routine is "GetFilesInFolderA (folder As Folderitem,fArray() As folder item) - so if it is a directory it calls itself.
You get all files on a drive , even it is in a folder or not.

If i run this routine in a small program on RB2011R4 everything works ok. If i call this from a Thread .... it the time consumption is horrible.
Any ideas ?

THX Thomas

Author:  jranieri [ Sun Jan 08, 2012 10:15 am ]
Post subject:  Re: Folderitems and Realstudio 2011 R 4 slowdown

thomas wrote:
for i as Integer = 1 to count
if folder.trueItem( i ) <> nil then
fx = folder.trueItem( i )


Don't call TrueItem() multiple times. Instead, cache the item you get back into a variable and use that for everything. <feedback://showreport?report_id=19551>

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/