X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=microbench%2F32kreadbench.py;fp=microbench%2F32kreadbench.py;h=1c07cd6821461dd4873a0bd203092c6445203342;hb=5a120ff89ded112b2255619a26946dccae8ce539;hp=0000000000000000000000000000000000000000;hpb=5a40d2aa7804d0233f645098bb608a6de887bd71;p=bluesky.git diff --git a/microbench/32kreadbench.py b/microbench/32kreadbench.py new file mode 100755 index 0000000..1c07cd6 --- /dev/null +++ b/microbench/32kreadbench.py @@ -0,0 +1,24 @@ +#!/usr/bin/python + +import os, random, sys, time + +def read_files(files, rate=1.0): + while True: + f = random.sample(files, 1)[0] + + start = time.time() + fp = open(f, 'r') + blocks = (16 << 20) / 32768 + offset = random.randrange(blocks) * 32768 + fp.seek(offset) + fp.read(32768) + print time.time() - start + fp.close() + +if __name__ == '__main__': + all_files = [] + for (path, dirs, files) in iter(os.walk(".")): + for f in files: + all_files.append(os.path.join(path, f)) + print len(all_files), "files total" + read_files(all_files)