Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import datetime
- from progressbar import ProgressBar
- for n in range(1000, 1000001, 1000):
- a = 0
- a_start = datetime.datetime.now()
- for i in range(n):
- a += i
- a_end = datetime.datetime.now()
- b = 0
- b_start = datetime.datetime.now()
- with ProgressBar(max_value=n) as pb:
- for i in range(n):
- b += i
- pb.update(i)
- b_end = datetime.datetime.now()
- a_diff = (a_end - a_start).total_seconds()
- b_diff = (b_end - b_start).total_seconds()
- with open('results.csv', 'a+') as f:
- f.write('{},{},{},{}\n'.format(n, a_diff, b_diff, b_diff - a_diff))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement