Last active
September 6, 2021 04:37
-
-
Save chand1012/97ad4d0623a71c30a46df96e72aa93d5 to your computer and use it in GitHub Desktop.
File to test the buffer size for os.read. Requires humanize to be installed. See here for license: https://chand1012.mit-license.org/
This file contains hidden or 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 sys | |
import humanize | |
file_path = sys.argv[1] | |
size = os.path.getsize(file_path) | |
print(f'Size in bytes: {humanize.naturalsize(size, binary=True)}') | |
video = os.open(file_path, os.O_RDONLY) | |
video_buffer = os.read(video, size) | |
print(f'Video buffer size: {humanize.naturalsize(sys.getsizeof(video_buffer), binary=True)}') | |
# Call like so: python3 buffersize.py /path/to/file.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment