Advertisement
Guest User

Test progressbar2

a guest
Feb 4th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import datetime
  5.  
  6. from progressbar import ProgressBar
  7.  
  8. for n in range(1000, 1000001, 1000):
  9.     a = 0
  10.     a_start = datetime.datetime.now()
  11.     for i in range(n):
  12.         a += i
  13.     a_end = datetime.datetime.now()
  14.  
  15.     b = 0
  16.     b_start = datetime.datetime.now()
  17.     with ProgressBar(max_value=n) as pb:
  18.         for i in range(n):
  19.             b += i
  20.             pb.update(i)
  21.     b_end = datetime.datetime.now()
  22.  
  23.     a_diff = (a_end - a_start).total_seconds()
  24.     b_diff = (b_end - b_start).total_seconds()
  25.  
  26.     with open('results.csv', 'a+') as f:
  27.         f.write('{},{},{},{}\n'.format(n, a_diff, b_diff, b_diff - a_diff))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement