Created
May 3, 2020 13:30
-
-
Save JAEarly/5d56d3eb6f2291f77a87197b5d96bc05 to your computer and use it in GitHub Desktop.
Python Demo: Logging Memory Usage
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 resource | |
def log_memory_usage(): | |
# On linux, defaults to KB | |
memory_usage_kb = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss | |
# Convert to GB | |
memory_usage_gb = memory_usage_kb / 1000000 | |
# Output | |
print("Memory Usage: {:.3f}GB".format(memory_usage_gb)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment