From 7f7b701df4015f2ac3ea62e7b85c7a587456fef8 Mon Sep 17 00:00:00 2001 From: Pratik K Sarangi <81045908+psarangi550@users.noreply.github.com> Date: Thu, 24 Feb 2022 08:43:52 +0530 Subject: [PATCH] using the profile decorator for memory_profiler instead of mem_profile to plot the memory usage --- Generators/people.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Generators/people.py b/Generators/people.py index ad3317da6..2b8f568b0 100644 --- a/Generators/people.py +++ b/Generators/people.py @@ -1,4 +1,5 @@ import mem_profile +import memory_profiler import random import time @@ -7,6 +8,7 @@ print 'Memory (Before): {}Mb'.format(mem_profile.memory_usage_psutil()) +@memory_profiler.profile(precision=2) def people_list(num_people): result = [] for i in xrange(num_people): @@ -18,6 +20,7 @@ def people_list(num_people): result.append(person) return result +@memory_profiler.profile(precision=2) def people_generator(num_people): for i in xrange(num_people): person = { @@ -36,4 +39,4 @@ def people_generator(num_people): t2 = time.clock() print 'Memory (After) : {}Mb'.format(mem_profile.memory_usage_psutil()) -print 'Took {} Seconds'.format(t2-t1) \ No newline at end of file +print 'Took {} Seconds'.format(t2-t1)