Skip to content

Instantly share code, notes, and snippets.

@hyounggyu
Created August 1, 2017 01:10
Show Gist options
  • Save hyounggyu/cef99b30c7842f03d8992b826a620083 to your computer and use it in GitHub Desktop.
Save hyounggyu/cef99b30c7842f03d8992b826a620083 to your computer and use it in GitHub Desktop.
Disk usage using Python
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