Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A File is just a wrapper for the file path. It doesn't matter how big the file is only its file name.</p> <p>When you want to get the size of all the files in a directory, the OS needs to read the directory and then lookup each file to get its size. Each access takes about 10 ms (because that's a typical seek time for a hard drive) So if you have 100,000 file it will take you about 17 minutes to get all their sizes.</p> <p>The only way to speed this up is to get a faster drive. e.g. Solid State Drives have an average seek time of 0.1 ms but it would still take 10 second or more to get the size of 100K files.</p> <p>BTW: The size of each file doesn't matter because it doesn't actually read the file. Only the file entry which has it s size.</p> <hr> <p>EDIT: For example, if I try to get the sizes of a large directory. It is slow at first but much faster once the data is cached.</p> <pre><code>$ time du -s /usr 2911000 /usr real 0m33.532s user 0m0.880s sys 0m5.190s $ time du -s /usr 2911000 /usr real 0m1.181s user 0m0.300s sys 0m0.840s $ find /usr | wc -l 259934 </code></pre> <p>The reason the look up is so fast the fist time is that the files were all installed at once and most of the information is available continuously on disk. Once the information is in memory, it takes next to no time to read the file information.</p> <p>Timing FileUtils.sizeOfDirectory("/usr") take under 8.7 seconds. This is relatively slow compared with the time it takes du, but it is processing around 30K files per second.</p> <p>An alterative might be to run <code>Runtime.exec("du -s "+directory);</code> however, this will only make a few seconds difference at most. Most of the time is likely to be spent waiting for the disk if its not in cache.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload