473,378 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

speeding up reading opendir...

Hi!

I have a system, which reads in the entire tree - all files. As of
now, there are 1312 folders to read.

1st time it takes 53-60 seconds to read. The data is somehow cached,
2nd time time is takes 2-3 seconds.

Is there a way to "cache" data beforehand? Like "preparing" the
directory....?

WBR
Sonnich
Jan 9 '08 #1
3 1279
jodleren wrote:
Hi!

I have a system, which reads in the entire tree - all files. As of
now, there are 1312 folders to read.

1st time it takes 53-60 seconds to read. The data is somehow cached,
2nd time time is takes 2-3 seconds.

Is there a way to "cache" data beforehand? Like "preparing" the
directory....?
Before what? Before you read them?

Bit of a logical impasse there ;-)

If its *nix, you might execute a cron script every few minutes and read
the whole directory structure, which will bring it into the disk file cache.

Of course under heavy I/O load that caching may get flushed again..

WBR
Sonnich
Jan 9 '08 #2
On Jan 9, 9:34 am, jodleren <sonn...@hot.eewrote:
I have a system, which reads in the entire tree - all files. As of
now, there are 1312 folders to read.

1st time it takes 53-60 seconds to read. The data is somehow cached,
2nd time time is takes 2-3 seconds.

Is there a way to "cache" data beforehand? Like "preparing" the
directory....?

WBR
Sonnich
You might simply direct the output of the dir
command into a file (or string or array depending
on which exec type of command you use) and then
parse that yourself. It should be FAR faster.

For reference,
It took my Win XP system about 315 seconds to do:
C:\>dir /s delme.dir
with the entire c: drive, about 140000 files
totaling about 44 gigabytes in 32000 directories.
The resultant file was about 10 megabytes

Csaba Gabor from Vienna
Jan 9 '08 #3
Rob
On Jan 9, 12:56*pm, Csaba Gabor <dans...@gmail.comwrote:
On Jan 9, 9:34 am, jodleren <sonn...@hot.eewrote:
I have a system, which reads in the entire tree - all files. As of
now, there are 1312 folders to read.
1st time it takes 53-60 seconds to read. The data is somehow cached,
2nd time time is takes 2-3 seconds.
Is there a way to "cache" data beforehand? Like "preparing" the
directory....?
WBR
Sonnich

You might simply direct the output of the dir
command into a file (or string or array depending
on which exec type of command you use) and then
parse that yourself. *It should be FAR faster.

For reference,
It took my Win XP system about 315 seconds to do:
C:\>dir /s delme.dir
with the entire c: drive, about 140000 files
totaling about 44 gigabytes in 32000 directories.
The resultant file was about 10 megabytes

Csaba Gabor from Vienna
If you're running this on Windows, you're probably seeing the Windows
cache coming into play, which is why it runs faster the second time.

As previously suggested, try usign exec() to output a directory to a
file, and then parse that instead.
Rob.
Jan 9 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Oliver | last post by:
Hi, I wrote earlier this day about this problem but thought it had something to do with images. However, I found out that for some reason the readdir function is not working properly on my Suse...
9
by: Andrew DeFaria | last post by:
I'm attempting to put my music collection on the web using PHP and I hit a problem. When I attempt an opendir of a directory that contains a "'" character the opendir fails. Here's the code...
2
by: Alex | last post by:
Greetings all, I'm trying to use the "opendir" command on Win32 in a CGI script. I'm using Apache 2.0.48 for Win32. The "openDir" command works from the CGI script when I try to open a...
4
by: gnah | last post by:
Greetings, I hope my problem is easy to fix, I'm pretty new with php - but I am getting weird results with the opendir() function. It may just be a path problem, but I don't see which variable...
8
by: Tim | last post by:
Does anyone know a way to read the filenames from a given directory in C in a Solaris environment? I did this, but it seems goofy: sprintf(t, "ls *.csv > filenames.txt"); system(t); fptr =...
5
by: Markus Pitha | last post by:
Hello, i'm using Gentoo Linux and like to open directories which i got from a text file i read of. I tried to open a directory as i wrote the directory name directly into "opendir()" and it...
6
by: dmcglynn | last post by:
Hello all.. I have a strange issue. I am trying to do an opendir via a UNC path, from my windows server to another windows machine. As long as my remote machine is on a physically wired...
0
by: shilpagangadhara | last post by:
Hi All, I'm trying to open a directory and after getting the file names from the the directory i need to read the contents of the file. OS ----Unix Language C I have done the following:...
7
code green
by: code green | last post by:
I am trying to access files on a different drive but the same server to where the script is running. but I only get the error failed to open dir: Invalid argument in...
2
by: koti688 | last post by:
I have a directory named "X" which has many sub directorys "Y","Z","W" and many files about 20 files. and these sub directories also contain some more sub directories and files extra check the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.