How to make to create year estimate off research

Posted on 2006-11-15
Last Modified: 2010-04-05
I cuts the quantity off files to seek and it is necessary for the temp to me estimated that its take to curry it out.
Question by:ProgsX
  • 3
LVL 28

Expert Comment

ID: 17948732
first: you should probably use an online translator such as babelfish: it might get more comprehensible information. If there is no online translator for your language, then you should be more specific and as possible provide examples.

now, what I understood is that you want to do some processing (delete maybe?) and you want to know how much time it will take. When dealing with files and want to build a progress you need to know eitehr the total number of files or the total size of all files or something like that, in any case it implies that you loop through all files. this takes time. Now, some operations take aproximatly the same time as the looping itself. such an operation is delete.
so as a general rule, if an operaition takes as much time as the looping itself, there is no sense in doing the looping.
UNLESS, you can beat the looping by using some "tricks"/functions provided by the filesystem.

with NTFS you might be using the indexing service and maybe some other mambo jambo I never heard of (and russel for example might probably tell us sooner or later about such stuff) that will drastically reduce the time to do such a looping (finding out the number of the files for instance).

anyway, before getting too much into the matter: what exactly are you trying to do?
LVL 28

Expert Comment

ID: 18832856
may I know the reason for a C grade?

Author Comment

ID: 18843150
ok I read my question and yes it is true it is not clear for me.  excuse me.

My question was, how to create a function to estimate a research.

ex :  in my documents, the estimation time for find all files.
LVL 28

Accepted Solution

2266180 earned 125 total points
ID: 18843350
that will be in most cases impossible to do. I'll explain why:

- in order to estimate a processing (in your case finding all files) you need to know at least aproximatly (best would be to know exactly) how many files are there and how much time it takes to find one file. then you can multiply the 2 and you're done.
- unfortunatly, there is no way of knowing in advance how many files there are in a directory (at least not in fat/ntfs file systems, on which windows is running). if you don't believe me, go in windows explorer, right click the windows directory (or program files directory, in any case, something big) and click properties. you will see that the "size", "size on disk" and "contains" fields are constantly being updated until finish. if windows cannot do it, we can't either. this is because windows uses the only possible way of determining the total number of files and their attributes in a directory: loop through it.

so in this particular case, if you want to know how much time it will take to find a file in a directory, the short answer is: you cannot.
the longer answer is:
- you can, but it's not worth it. because, you will have to loop through all files in that directory, compute the time, and then, again, loop through all files in the directory and make the search. in the end, you will do the same operation twice, because the time it takes to calculate the total time and to search for a file is aproximatly the same. so let's take a small example: if your search takes 5 minutes, then finding out how much time it would take (presuming you don't know that it takes 5 minutes yet) will take aproximatly 5 minutes, so in the end, you will end up to spend 10 minutes for a 5 minute process: 5 minutes to find out the time and 5 minutes to do the search.

as I explained in my first post, this method is usefull in case you want to do time costly operations.
for example copy the files. or compute an md5/tth/etc hash, or crypt the file. these operations take a long time. in this case, it worths waiting 2 minutes to compute the time to inform the user that the actual process will take 5 hours. you can spare 2 minutes to inform the user of a 5 hour job ;) but it doesn't worth it to spend 2 minutes to inform the user that the operation will take 2 mintues. it also doesn't worth to spend 2 minutes if the operation takes 4 minutes. the difference is still too much.

so in such cases of non-time consuming jobs ( like searching, deleting, renaming files, etc) it is best to just show some kind of progress indicator (like the animations from windows in which a file goes from one end of the bar to the other, or some bar floats around, etc) so that the user will know that the process is going on and the system did not freeze.
another way of informing the user is to use a statusbar and display in it the current file or directory being processed, this way the user has a more realisting progress of the job.

so bottom line: all jobs can be estimated of the time they need to finish; but not all of them worth the effort of doing so.

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question