Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf8 -*-
- from time import time
- from sys import argv
- open_us = read_us = close_us = 0
- for file in argv[1:]:
- start = time()
- with open(file) as f:
- opened = time()
- _ = f.read(4096)
- read = time()
- end = time()
- this_open_us = (opened - start) * 1000000
- this_read_us = (read - opened) * 1000000
- this_close_us = (read - opened) * 1000000
- print "%s: %dµs + %dus + %dµs" % (file, this_open_us, this_read_us, this_close_us)
- open_us += this_open_us
- read_us += this_read_us
- close_us += this_close_us
- count = len(argv) - 1
- open_us /= count
- close_us /= count
- print "Avg Latency: %dµs + %dµs + %dµs = %dµs" % (open_us, this_read_us, close_us, open_us + read_us + close_us)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement