stats.py 806 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python2
  2. import struct
  3. import sys
  4. import time
  5. import os
  6. import re
  7. def main():
  8. with open('blocks/.config') as file:
  9. s = struct.unpack('<LLLL', file.read())
  10. print 'read_size: %d' % s[0]
  11. print 'prog_size: %d' % s[1]
  12. print 'block_size: %d' % s[2]
  13. print 'block_size: %d' % s[3]
  14. print 'real_size: %d' % sum(
  15. os.path.getsize(os.path.join('blocks', f))
  16. for f in os.listdir('blocks') if re.match('\d+', f))
  17. with open('blocks/.stats') as file:
  18. s = struct.unpack('<QQQ', file.read())
  19. print 'read_count: %d' % s[0]
  20. print 'prog_count: %d' % s[1]
  21. print 'erase_count: %d' % s[2]
  22. print 'runtime: %.3f' % (time.time() - os.stat('blocks').st_ctime)
  23. if __name__ == "__main__":
  24. main(*sys.argv[1:])