MacBook Air OS X El Capitan Processor 1.4GHz Intel Core i5 Memory 4GB 1600 MHz DDR3
https://yakst.com/ja/posts/42 With reference to
pip install -U memory_profiler
pip install psutil
Just count 10,000 times
count10k.py
#!/usr/bin/env python
import time
def main():
start = time.time()
j = 0
for i in range(10000):
j += 1
print ("elapsed_time:{0}".format(time.time() - start)) + "[sec]"
if __name__ == "__main__": main()
mem_count10k.py
#!/usr/bin/env python
import time
@profile
def main():
start = time.time()
j = 0
for i in range(10000):
j += 1
print ("elapsed_time:{0}".format(time.time() - start)) + "[sec]"
if __name__ == "__main__": main()
$ python count10k.py
elapsed_time:0.00121402740479[sec]
$ python -m memory_profiler mem_count10k.py
elapsed_time:0.404528856277[sec]
It's about 350 times different. I wonder if it's bad to use
Recommended Posts