Task

Beginning from the current directory, or optionally from a directory specified as a command-line argument, determine how many files there are of various sizes in a directory hierarchy.



My suggestion is to sort by logarithmn of file size, since a few bytes here or there, or even a factor of two or three, may not be that significant.

Don't forget that empty files may exist, to serve as a marker.



Is your file system predominantly devoted to a large number of smaller files, or a smaller number of huge files?




pipe:=Thread.Pipe();
    // hoover all files in tree, don't return directories
fcn(pipe,dir){ File.globular(dir,"*",True,8,pipe); }
.launch(pipe,vm.arglist[0]);  // thread
 
dist,N,SZ,maxd:=List.createLong(50,0),0,0,0;
foreach fnm in (pipe){
   sz,szd:=File.len(fnm), sz.numDigits;
   dist[szd]+=1;
   N+=1; SZ+=sz; maxd=maxd.max(szd);
}
println("Found %d files, %,d bytes, %,d mean.".fmt(N,SZ,SZ/N));
scale:=50.0/(0.0).max(dist);
szchrs,idx,comma:=",nnn"*20, -1, Walker.cycle(0,0,1).next;
println("%15s   %s (* = %.2f)".fmt("File size","Number of files",1.0/scale));
foreach sz,cnt in ([0..].zip(dist[0,maxd])){
   println("%15s : %s".fmt(szchrs[idx,*], "*"*(scale*cnt).round().toInt()));
   idx-=1 + comma();
}