This function quickly calculates the size of a directory:
http://aidanlister.com/repos/v/function.dirsize.php
You can convert filesizes to a human readable size using:
http://aidanlister.com/repos/v/function.size_readable.php
For a faster (unix only) implementation, see function.disk-total-space, note #34100
http://www.php.net/manual/en/function.disk-total-space.php#34100
Also of interest is this wikipedia article, discussing the difference between a kilobyte (1000) and a kibibyte (1024).
http://en.wikipedia.org/wiki/Bytes