Starting work on scripts to automate benchmarking.
[bluesky.git] / microbench / microbench.py
1 #!/usr/bin/python
2
3 import os, subprocess, sys, time
4
5 MNTDIR = '/mnt/bluesky'
6 SERVER = 'c09-45.sysnet.ucsd.edu'
7
8 class TestClient:
9     def setup_client(self, export):
10         subprocess.check_call(['mount', '-t', 'nfs',
11                                '-o', 'vers=3,tcp,rw,soft,intr',
12                                export, MNTDIR])
13
14     def cleanup_client(self):
15         subprocess.check_call(['umount', '-f', MNTDIR])
16
17     def run(self, export):
18         self.setup_client(export)
19         try:
20             results = self.run_test()
21         finally:
22             self.cleanup_client()
23         return results
24
25 class BlueSkyServer:
26     def setup_server(self):
27         subprocess.call(['ssh', SERVER, ''])
28
29 class SerialStat(TestClient):
30     """Call stat() on a set of files sequentially and measure the response time
31     for each call."""
32
33     def run_test(self):
34         files = [MNTDIR + "/file-%d" % (i,) for i in range(8)]
35
36         times = []
37         for f in files:
38             start = time.time()
39             os.stat(f)
40             times.append(time.time() - start)
41
42         return times
43
44 if __name__ == '__main__':
45     test = SerialStat()
46     print test.run('niniel.sysnet.ucsd.edu:/export')