Created
August 1, 2017 01:10
-
-
Save hyounggyu/cef99b30c7842f03d8992b826a620083 to your computer and use it in GitHub Desktop.
Disk usage using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
start_time = time.time() | |
total_size = 0 | |
for dirpath, _, _ in os.walk("."): | |
with os.scandir(dirpath) as it: | |
for entry in it: | |
if entry.is_file(follow_symlinks=False): | |
total_size += entry.stat().st_size | |
wall_time = time.time() - start_time | |
print(total_size) | |
print(wall_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment