Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 151
  • Last Modified:

How to make to create year estimate off research

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.
  • 3
1 Solution
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?
may I know the reason for a C grade?
ProgsXAuthor Commented:
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.
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now