MacBook Air OS X El Capitan Prozessor 1,4 GHz Intel Core i5 Speicher 4 GB 1600 MHz DDR3
https://yakst.com/ja/posts/42 Mit Bezug auf
pip install -U memory_profiler
pip install psutil
Zähle einfach 10.000 Mal
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]