Solved

How to make to create year estimate off research

Posted on 2006-11-15
7
142 Views
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.
0
Comment
Question by:ProgsX
  • 3
7 Comments
 
LVL 28

Expert Comment

by:ciuly
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?
0
 
LVL 28

Expert Comment

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

Author Comment

by:ProgsX
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.
0
 
LVL 28

Accepted Solution

by:
ciuly 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.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now