Skip to content

Instantly share code, notes, and snippets.

@ds7711
Created October 16, 2016 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ds7711/85261bf1f484cb79e65b3fb27f153d91 to your computer and use it in GitHub Desktop.
Save ds7711/85261bf1f484cb79e65b3fb27f153d91 to your computer and use it in GitHub Desktop.
test measure_memory_usage
def SomeLongRunningLibraryCall(arg1, arg2):
import time
max_dict_entries = 2500
delay_per_entry = .005
some_large_dictionary = {}
dict_entry_count = 0
while(1):
time.sleep(delay_per_entry)
dict_entry_count += 1
some_large_dictionary[dict_entry_count]=range(20000)
if dict_entry_count % 100 == 0:
print dict_entry_count
if len(some_large_dictionary) > max_dict_entries:
break
print arg1 + " " + arg2
return "Good Bye World"
from memory_usage import measure_memory_usage
memory_usage = measure_memory_usage(SomeLongRunningLibraryCall, ("Hello", "world"))
print memory_usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment