Advertisement
rfmonk

time_clock.py

Jan 16th, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. # Note
  4. # If you want to run this on your system you
  5. # may have to add more cycles to the inner
  6. # loop or work with a larger amount of data.
  7. # Credit for this code goes to the book
  8. # from Oreilly "Python Standard Library..."
  9.  
  10. import hashlib
  11. import time
  12.  
  13. # Data to use to calculate md5 checksums
  14. data = open(__file__, 'rt').read()
  15.  
  16. for i in range(5):
  17.     h = hashlib.sha1()
  18.     print time.ctime(), ': %0.3f %0.3f' % (time.time(),
  19.                                            time.clock())
  20.     for i in range(300000):
  21.         h.update(data)
  22.     cksum = h.digest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement