File size distribution: Difference between revisions

Content added Content deleted
Line 453: Line 453:
) (0, 0)
) (0, 0)


groupsFromGroup :: [Integer] -> FrequencyGroup -> [FrequencyGroup]
groupsFromGroup :: Int -> [Integer] -> FrequencyGroup -> [FrequencyGroup]
groupsFromGroup fileSizes ((min, max), count) = frequencyGroups 10 range
groupsFromGroup gsize fileSizes ((min, max), count) = frequencyGroups gsize range
where
where
collectBetween min max = filter (\n -> n >= min && n <= max)
collectBetween min max = filter (\n -> n >= min && n <= max)
range = collectBetween min max fileSizes
range = collectBetween min max fileSizes


expandGroups :: [Integer] -> Integer -> [FrequencyGroup] -> [FrequencyGroup]
expandGroups :: Int -> [Integer] -> Integer -> [FrequencyGroup] -> [FrequencyGroup]
expandGroups fileSizes groupThreshold groups
expandGroups gsize fileSizes groupThreshold groups
| all ((<= groupThreshold) . snd) groups = groups
| all ((<= groupThreshold) . snd) groups = groups
| otherwise = expandGroups fileSizes groupThreshold $ expand groups
| otherwise = expandGroups gsize fileSizes groupThreshold $ expand groups
where
where
expand = ((\g@((min, max), count) ->
expand = ((\g@((min, max), count) ->
if count > groupThreshold then
if count > groupThreshold then
groupsFromGroup fileSizes g
groupsFromGroup gsize fileSizes g
else
else
[g]
[g]
Line 549: Line 549:
putStrLn "\nDistribution:"
putStrLn "\nDistribution:"
let results = filteredGroups groupSize items
let results = filteredGroups groupSize items
deepResults = expandedGroups (sizes items) (groupThreshold fileCount) results
deepResults = expandedGroups groupSize (sizes items) (groupThreshold fileCount) results
mapM_ (displayFrequency fileCount) deepResults
mapM_ (displayFrequency fileCount) deepResults
where
where
Line 555: Line 555:
filteredGroups n = filter ((>0) . snd) . frequencyGroups n . sizes
filteredGroups n = filter ((>0) . snd) . frequencyGroups n . sizes
groupThreshold = round . (*0.25) . realToFrac
groupThreshold = round . (*0.25) . realToFrac
expandedGroups sizes n = filter ((>0) . snd) . expandGroups sizes n</lang>
expandedGroups gsize sizes n = filter ((>0) . snd) . expandGroups gsize sizes n</lang>
{{out}}
{{out}}
<pre style="height: 50rem;">$ filedist
<pre style="height: 50rem;">$ filedist
Using 4 worker threads
Using 4 worker threads
Total files: 431798
Total files: 431803
Total folders: 65528
Total folders: 65528
Total size: 6GB
Total size: 6GB


Distribution:
Distribution:
0B <-> 75B = 39305 9.103%: ████████████████████████████████████
0B <-> 83B = 43580 10.093%: ████████████████████████████████████████
76B <-> 151B = 36175 8.378%: ██████████████████████████████████
84B <-> 167B = 40942 9.482%: ██████████████████████████████████████
152B <-> 227B = 27747 6.426%: ██████████████████████████
168B <-> 251B = 24867 5.759%: ███████████████████████
228B <-> 303B = 19148 4.434%: ██████████████████
252B <-> 335B = 20019 4.636%: ███████████████████
301B <-> 601B = 50919 11.792%: ███████████████████████████████████████████████
336B <-> 419B = 15623 3.618%: ██████████████
602B <-> 902B = 41885 9.700%: ███████████████████████████████████████
420B <-> 503B = 13403 3.104%: ████████████
903B <-> 1KB = 43986 10.187%: █████████████████████████████████████████
504B <-> 587B = 12778 2.959%: ████████████
1KB <-> 2KB = 61277 14.191%: █████████████████████████████████████████████████████████
588B <-> 671B = 12125 2.808%: ███████████
2KB <-> 4KB = 29473 6.826%: ███████████████████████████
672B <-> 755B = 12736 2.950%: ████████████
4KB <-> 5KB = 17620 4.081%: ████████████████
756B <-> 839B = 9565 2.215%: █████████
5KB <-> 9KB = 28951 6.705%: ███████████████████████████
826B <-> 2KB = 83110 19.247%: █████████████████████████████████████████████████████████████████████████████
9KB <-> 14KB = 10941 2.534%: ██████████
2KB <-> 2KB = 34092 7.895%: ████████████████████████████████
14KB <-> 19KB = 5139 1.190%: █████
2KB <-> 3KB = 20814 4.820%: ███████████████████
19KB <-> 37KB = 8589 1.989%: ████████
3KB <-> 4KB = 15088 3.494%: ██████████████
4KB <-> 5KB = 10327 2.392%: ██████████
37KB <-> 56KB = 3100 0.718%: ███
5KB <-> 6KB = 7608 1.762%: ███████
56KB <-> 75KB = 1807 0.418%: ██
6KB <-> 6KB = 6260 1.450%: ██████
75KB <-> 150KB = 2547 0.590%: ██
6KB <-> 7KB = 4562 1.057%: ████
150KB <-> 225KB = 933 0.216%:
7KB <-> 8KB = 3894 0.902%: ████
225KB <-> 300KB = 697 0.161%:
301KB <-> 601KB = 653 0.151%:
8KB <-> 16KB = 18833 4.362%: █████████████████
16KB <-> 24KB = 6188 1.433%: ██████
601KB <-> 902KB = 305 0.071%:
24KB <-> 32KB = 3342 0.774%: ███
902KB <-> 1MB = 122 0.028%:
32KB <-> 40KB = 2100 0.486%: ██
1MB <-> 2MB = 210 0.049%:
40KB <-> 48KB = 1447 0.335%:
2MB <-> 4MB = 110 0.025%:
48KB <-> 56KB = 966 0.224%:
4MB <-> 5MB = 51 0.012%:
56KB <-> 64KB = 726 0.168%:
5MB <-> 9MB = 52 0.012%:
64KB <-> 72KB = 852 0.197%:
9MB <-> 14MB = 19 0.004%:
72KB <-> 81KB = 563 0.130%:
14MB <-> 19MB = 8 0.002%:
81KB <-> 161KB = 2368 0.548%: ██
20MB <-> 40MB = 17 0.004%:
161KB <-> 242KB = 967 0.224%:
40MB <-> 61MB = 5 0.001%:
242KB <-> 322KB = 558 0.129%:
61MB <-> 81MB = 3 0.001%:
322KB <-> 403KB = 287 0.066%:
403KB <-> 483KB = 176 0.041%:
483KB <-> 564KB = 100 0.023%:
564KB <-> 644KB = 77 0.018%:
644KB <-> 725KB = 101 0.023%:
725KB <-> 805KB = 77 0.018%:
815KB <-> 2MB = 282 0.065%:
2MB <-> 2MB = 123 0.028%:
2MB <-> 3MB = 74 0.017%:
3MB <-> 4MB = 59 0.014%:
4MB <-> 5MB = 26 0.006%:
5MB <-> 6MB = 17 0.004%:
6MB <-> 6MB = 20 0.005%:
6MB <-> 7MB = 7 0.002%:
7MB <-> 8MB = 6 0.001%:
8MB <-> 16MB = 23 0.005%:
16MB <-> 24MB = 10 0.002%:
24MB <-> 32MB = 9 0.002%:
32MB <-> 40MB = 4 0.001%:
40MB <-> 49MB = 5 0.001%:
73MB <-> 81MB = 3 0.001%:
98MB <-> 196MB = 8 0.002%:
98MB <-> 196MB = 8 0.002%:
294MB <-> 392MB = 1 0.000%: </pre>
294MB <-> 392MB = 1 0.000%: </pre>


=={{header|Julia}}==
=={{header|Julia}}==