标签:log port profile color 性能测试 profiler mem prime 安装
使用pip安装Python扩展库memory_profiler
1 from memory_profiler import profile 2 3 @profile #修饰器 4 def isPrime(n): 5 if n == 2: 6 return True 7 for i in range(2,int(n**0.5)+2): 8 if n%i == 0: 9 return False 10 return True 11 12 isPrime(99999999999999999999999999999999) 13 14 15 ‘‘‘ 16 Line # Mem usage Increment Line Contents 17 ================================================ 18 3 10.9 MiB 0.0 MiB @profile #修饰器 19 4 def isPrime(n): 20 5 10.9 MiB 0.0 MiB if n == 2: 21 6 return True 22 7 10.9 MiB 0.0 MiB for i in range(2,int(n**0.5)+2): 23 8 10.9 MiB 0.0 MiB if n%i == 0: 24 9 10.9 MiB 0.0 MiB return False 25 10 return True 26 ‘‘‘
标签:log port profile color 性能测试 profiler mem prime 安装
原文地址:http://www.cnblogs.com/cmnz/p/7049766.html