maybe if we look at your File::Find code, we can see some improvements?
Update: This is the fastest way that I know how, that also satisfies "multi-platform". This code runs on my Windows machine.
One "expensive" file operation is run for each file system entry. The results of that "file system query", "stat" operation are re-used in a subsequent file operation. This is multi-platform, but not completely optimal for Windows NTFS.#!/usr/bin.perl -w use strict; use File::Find; my $byte_total; my $file_total; find (\&sum_bytes, "C:/temp"); sub sum_bytes { return() unless (-f $File::Find::name); $byte_total += -s _; # not a typo! # "_" different than "$_"! # see [id://951317] $file_total++; } print "total bytes in C:/temp: $byte_total in $file_total files\n"; # prints on my Windows system: # total bytes in C:/temp: 656201485 in 2554 files
You can get "fastest" and you can get "multi-platform", but not both together. There is a Windows NTFS way to get this number faster. But this is the "fastest" multi-platform solution of which I am aware.
In reply to Re^2: Fastest way to calculate directory size in linux
by Marshall
in thread Fastest way to calculate directory size in linux
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |