LAVA Forums Buy cool LAVA gear Forums RSS Feed

Welcome Guest ( Log In | Register )

> Related links

Check out our General Code Repository Files. Also, before posting here, check to see if your post doesn't fit into another subforum by category.


Tags
(This content has not been tagged yet)
 
Closed Topic Start new topic
> Recursive Directory Listing VI, (OpenG submission candidate)
sam
post Feb 19 2004, 04:27 PM
Post #1


More Active
**

Member
Posts: 36
Joined: 20-October 02
From: Toroto
Member No.: 12
Using LabVIEW Since:1997
LV:8.20 ,. ,.
Canada Nothing Selected Nothing Selected


This VI give the directory listing of files and directories, it is also able to do a recursive listing. I was using the OpenG VI but that could not handle very large directories efficiently.

Any comments are welcome.

-Sam
Attached File(s)
Attached File  Dir_List_6x.vi ( 97.59K ) Number of downloads: 481
 


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Ad
post Feb 19 2004, 04:27 PM
Post #















Tags
(This content has not been tagged yet)
Go to the top of the page
Quote Post
Jim Kring
post Feb 19 2004, 05:30 PM
Post #2


Changing the world, one VI at a time.
*****

JKI
Posts: 1697
Joined: 22-October 02
From: San Francisco, CA
Member No.: 17
Using LabVIEW Since:1995
LV:8.2.1 ,8.5 ,7.1.1
United States us_california Nothing Selected My Blog My Gallery


QUOTE (sam @ Feb 19 2004, 08:27 AM)
This VI give the directory listing of files and directories, it is also able to do a recursive listing.  I was using the OpenG VI but that could not handle very large directories efficiently.

Any comments are welcome.

-Sam

Hi Sam,

lightbulb2.gif I was wondering if you are interested in helping to make the OpenG version more efficient. Perhaps you would want to contribute some of your improvements.

Cheers,

-Jim Kring

--------------------
-----------------------------------------------------------------------------------------------------
| Book | OpenG | LAVA | Champion | VIPM | Builder | Blog | JKI |
-----------------------------------------------------------------------------------------------------


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Michael_Aivaliot...
post Feb 20 2004, 05:38 AM
Post #3


Confucius say: Crowded elevator always smell different to midget
Group Icon
*****

Admin
Posts: 2367
Joined: 13-October 02
From: Planet Earth
Member No.: 2
Using LabVIEW Since:1994
LV:8.5 ,8.2.1 ,7.1.1
Greece Canada United States My Blog My Gallery


QUOTE (sam @ Feb 19 2004, 11:27 AM)
Any comments are welcome.

It took me a while to grasp why your VI would be more efficient than other implementations. I have my own version that is more efficient than the OpenG version as well. I compared my approach to yours and noticed no performance benefit on several thousand files and directories.

I noticed that you are initializing an array of filepaths to 500 items. You resize and build an array of another 500 items at a time when you require it. This seems like an excellent approach however as i said, this didn't show up in the performance comparisons I did between my version and yours. When is the benefit evident?

I also noticed that Windows does some caching of directory access. This seems apparent when you run a recursive search for the first time regardless of what implementation you choose.

I've attached my version (LV7). Let's compare notes... smile.gif
Attached File(s)
Attached File  Michael_Aivaliotis___List_Directory_Recursivly.vi ( 43.63K ) Number of downloads: 357
 

--------------------


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
sam
post Feb 21 2004, 12:57 AM
Post #4


More Active
**

Member
Posts: 36
Joined: 20-October 02
From: Toroto
Member No.: 12
Using LabVIEW Since:1997
LV:8.20 ,. ,.
Canada Nothing Selected Nothing Selected


Hi Jim,

Sure, I have benefited from OpenG and I am more than happy to give back.

-Sam


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
sam
post Feb 21 2004, 01:05 AM
Post #5


More Active
**

Member
Posts: 36
Joined: 20-October 02
From: Toroto
Member No.: 12
Using LabVIEW Since:1997
LV:8.20 ,. ,.
Canada Nothing Selected Nothing Selected


hi Michael,

I really like your approach; for most of my algorithms (solutions) that I like, they are best implemented in a text language, that way recursive algorithms really shows their power. I am certain we take something’s from each solution and get a better one.

I was trying to avoid memory allocation in a loop because I thought that would slow things down and at end it will crash it. What do think?

-Sam

This post has been edited by sam: Feb 21 2004, 01:07 AM


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Dean Mills
post Apr 8 2004, 11:31 PM
Post #6


Active
*

Member
Posts: 10
Joined: 18-October 02
From: Canada
Member No.: 5
Using LabVIEW Since:1996
LV:8.6 ,. ,.
Canada Nothing Selected Nothing Selected


Hi Mike, Sam, Jim

In my recursive directory listing I ignore Windows shortcuts. We had a Coop student accidentally create a a shortcut to the same directory the shortcut was in. Caused a good infinite loop and few hours to figure out why the software was filling all the memory. You can steal a prototype from the Tree example (called Directory Hierarchy in Tree Control.vi) in LabVIEW 7. The shortcut check is called Validate.vi.


Dean Mills
Meikle Automation

--------------------
Dean Mills
Meikle Automation


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
rolfk
post Apr 9 2004, 07:41 AM
Post #7


<customize this text>
*****

Premium Member
Posts: 1012
Joined: 9-April 04
From: Rotterdam
Member No.: 349
Using LabVIEW Since:1992
LV:8.5.1 ,8.2.1 ,7.1.1
Netherlands Switzerland Nothing Selected


Hi Michael

I just took a look at your List Directory and thought there would be something to improve.

Look at the attached version. On my computer it is almost two times faster in enumerating large directory trees even if it is called first in the timing test to not give it advantage through Windows directory list caching.
Attached File(s)
Attached File  Rolf_Kalbermatter___List_Directory_Recursivly_1.vi ( 37.94K ) Number of downloads: 333
 


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Michael_Aivaliot...
post Apr 13 2004, 02:05 AM
Post #8


Confucius say: Crowded elevator always smell different to midget
Group Icon
*****

Admin
Posts: 2367
Joined: 13-October 02
From: Planet Earth
Member No.: 2
Using LabVIEW Since:1994
LV:8.5 ,8.2.1 ,7.1.1
Greece Canada United States My Blog My Gallery


QUOTE (damsem @ Apr 8 2004, 06:31 PM)
In my recursive directory listing I ignore Windows shortcuts.  We had a Coop student accidentally create a a shortcut to the same directory the shortcut was in.  Caused a good infinite loop and few hours to figure out why the software was filling all the memory.  You can steal a prototype from the Tree example (called Directory Hierarchy in Tree Control.vi) in LabVIEW 7.  The shortcut check is called Validate.vi.

Yes Dean this is a great idea. I took a look at the VI you were writing about. I have an issue however with the label that NI gave to the indicator. It should not be labeled "Shortcut or not a path?". That implies that the boolean will be true if it's a shortcut or not a path, which it is not. It would be better to call it "Valid Path?". If you look at the icon it says "Valid?" right on it. I know this is minor, but still unacceptable in my opinion. Either you apply standards to your coding or you don't.

In any case...

It seems simple enough to integrate this code into the Recursive Directory Listing VI. It would make sense to add it into Rolf's version since it appears to be the fastest. I guess a switch to turn link checking on or off would be nice too. I will take all the suggestions and enhancements in this topic and create a VI which can then be submitted to the OpenG library. Whoever has submitted versions or suggestions to this topic will be given credit. Personally I use the OpenG library quite a bit however I don't use certain VI's in it because they are not optimized. This is our chance to help out and create a VI that we can all use.

Since most of you who have posted here are already willing to share your code, I will assume that you agree with the OpenG licensing. However if you are not familier with it, please read it over here. You must agree to this license if you want to participate.

So, on that note, can anyone suggest any other improvements to the VI's listed in this topic? You can take a previously submitted VI and re-write it (like Rolf did) or create another approach. I will work on creating a test routine to provide performance checking. If you have suggestions on a test VI please let me know or just submit it here.
Attached thumbnail(s)
Attached Image
 

--------------------


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Jim Kring
post Apr 13 2004, 02:09 AM
Post #9


Changing the world, one VI at a time.
*****

JKI
Posts: 1697
Joined: 22-October 02
From: San Francisco, CA
Member No.: 17
Using LabVIEW Since:1995
LV:8.2.1 ,8.5 ,7.1.1
United States us_california Nothing Selected My Blog My Gallery


QUOTE (Michael Aivaliotis @ Apr 12 2004, 06:05 PM)
So, on that note, can anyone suggest any other improvements to the VI's listed in this topic?

I will check to see how symbolic links (unix shortcuts) are handled in linux.

--------------------
-----------------------------------------------------------------------------------------------------
| Book | OpenG | LAVA | Champion | VIPM | Builder | Blog | JKI |
-----------------------------------------------------------------------------------------------------


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
sam
post Apr 15 2004, 04:06 PM
Post #10


More Active
**

Member
Posts: 36
Joined: 20-October 02
From: Toroto
Member No.: 12
Using LabVIEW Since:1997
LV:8.20 ,. ,.
Canada Nothing Selected Nothing Selected


One thing Michaels' code allows to do is to be able to add the capability to define file patterns.

If you pass anything but *.* or leave unwired you will not get back any Folder names.

I myself use file patterns.

I have changed mine and removed the FOR loop for the file names and brought the whole thing inside the WHILE loop and the same steps for folder is done on files.

I would post it again but your approach is much easier on the eyes.


-Sam

This post has been edited by sam: Apr 15 2004, 04:07 PM


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
rolfk
post Apr 21 2004, 12:18 PM
Post #11


<customize this text>
*****

Premium Member
Posts: 1012
Joined: 9-April 04
From: Rotterdam
Member No.: 349
Using LabVIEW Since:1992
LV:8.5.1 ,8.2.1 ,7.1.1
Netherlands Switzerland Nothing Selected


QUOTE
One thing Michaels' code allows to do is to be able to add the capability to define file patterns.

If you pass anything but *.* or leave unwired you will not get back any Folder names.


Well that is not entirely true. It's only true because you usually don't have folders with endings but if you name your folders for instance Folder.dir a search pattern of *.dir will return those folders. Of course I agree with you that looking for particular file patterns is a nice feature and I thought the OpenG version does that also. The problem with this is the requirement of the two List Directory Nodes for each hierarchy level which will almost take double the time than one node does.

I think with preallocating the arrays and such one can win another few percent but the real time spent is in the List Directory node.

This post has been edited by rolfk: Apr 21 2004, 12:18 PM


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Michael_Aivaliot...
post Jun 4 2004, 08:36 PM
Post #12


Confucius say: Crowded elevator always smell different to midget
Group Icon
*****

Admin
Posts: 2367
Joined: 13-October 02
From: Planet Earth
Member No.: 2
Using LabVIEW Since:1994
LV:8.5 ,8.2.1 ,7.1.1
Greece Canada United States My Blog My Gallery


All this talk on Info-LabVIEW lately regarding recursive algorithms has prompted me to post a version of the Recursive directory listing VI that uses true recursion in LabVIEW. By this I mean using a VI that lists the directory structure of one directory and then have that VI call itself for any subdirectories it may find along the way.

I realize this setup creates a huge performance hit however I think it should be included in this posting for completeness so it can be compared to other implementations.

Enjoy.
Attached File(s)
 

--------------------


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
brian175
post Nov 9 2004, 07:24 PM
Post #13


Very Active
***

Member
Posts: 70
Joined: 9-November 04
Member No.: 987
LV:7.0


QUOTE (Michael_Aivaliotis @ Jun 4 2004, 04:36 PM)
I realize this setup creates a huge performance hit


Here's a modified version of Michael's VI that doesn't have a "huge" performance hit. The trick is to minimize the number of times that the VI calls itself (due to the Open VI reference call). On my computer the listing of the LabVIEW directory took the following times:
Michael"s VI 2399 (ms)
Rolf K's VI 478 (ms)
Michael's VI modified 552 (ms)
OpenG 6717 (ms)
The test VI as well as Michael's and Rolf's original VIs are included.

Brian
Attached File(s)
 

--------------------
Brian Gangloff
DataAct Incorporated - NI Alliance Member
http://store.dataact.com/


Tags
(This content has not been tagged yet)
Go to the top of the page