projects
/
bluesky.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b58691
)
Updated microbenchmarking script.
author
Michael Vrable
<mvrable@cs.ucsd.edu>
Mon, 27 Sep 2010 05:55:19 +0000
(22:55 -0700)
committer
Michael Vrable
<mvrable@cs.ucsd.edu>
Mon, 27 Sep 2010 05:55:19 +0000
(22:55 -0700)
microbench/microbench.py
patch
|
blob
|
history
diff --git
a/microbench/microbench.py
b/microbench/microbench.py
index
3e0cd4d
..
313828a
100755
(executable)
--- a/
microbench/microbench.py
+++ b/
microbench/microbench.py
@@
-7,40
+7,81
@@
SERVER = 'c09-45.sysnet.ucsd.edu'
class TestClient:
def setup_client(self, export):
class TestClient:
def setup_client(self, export):
+ print "Mounting file system..."
subprocess.check_call(['mount', '-t', 'nfs',
'-o', 'vers=3,tcp,rw,soft,intr',
export, MNTDIR])
def cleanup_client(self):
subprocess.check_call(['mount', '-t', 'nfs',
'-o', 'vers=3,tcp,rw,soft,intr',
export, MNTDIR])
def cleanup_client(self):
+ print "Unmounting file system..."
subprocess.check_call(['umount', '-f', MNTDIR])
subprocess.check_call(['umount', '-f', MNTDIR])
- def run(self,
export
):
+ def run(self,
proc, args=(), export=(SERVER + ":/export")
):
self.setup_client(export)
self.setup_client(export)
+ startdir = os.getcwd()
try:
try:
- results = self.run_test()
+ os.chdir(MNTDIR)
+ results = proc(*args)
finally:
finally:
+ os.chdir(startdir)
self.cleanup_client()
return results
self.cleanup_client()
return results
-class
BlueSkyServer
:
- def se
tup_server
(self):
- subprocess.call(['ssh', SERVER, ''])
+class
TestCommands
:
+ def se
rial_stat
(self):
+ files = ["file-%d" % (i,) for i in range(8)]
-class SerialStat(TestClient):
- """Call stat() on a set of files sequentially and measure the response time
- for each call."""
+ times = []
+ for f in files:
+ start = time.time()
+ os.stat(f)
+ times.append(time.time() - start)
- def run_test(self):
- files = [MNTDIR + "/file-%d" % (i,) for i in range(8)]
+ return times
+
+ def serial_read(self):
+ files = ["file-%d" % (i,) for i in range(8)]
times = []
for f in files:
start = time.time()
times = []
for f in files:
start = time.time()
- os.stat(f)
+ open(f).read()
+ times.append(time.time() - start)
+
+ return times
+
+ def serial_write(self):
+ files = ["write-%d" % (i,) for i in range(8)]
+
+ times = []
+ buf = "A" * 32768
+ for f in files:
+ start = time.time()
+ fp = open(f, 'w')
+ fp.write(buf)
+ fp.close()
times.append(time.time() - start)
return times
times.append(time.time() - start)
return times
+ def large_write(self):
+ buf = "A" * 1048576
+
+ start = time.time()
+ fp = open("largefile", 'w')
+ for i in range(128): fp.write(buf)
+ fp.close()
+
+ return [time.time() - start]
+
+ def shell(self):
+ subprocess.call(['/bin/sh'])
+
if __name__ == '__main__':
if __name__ == '__main__':
- test = SerialStat()
- print test.run('niniel.sysnet.ucsd.edu:/export')
+ cmd = sys.argv[1]
+ args = sys.argv[2:]
+ if not cmd.startswith("_"):
+ fun = getattr(TestCommands(), cmd)
+ client = TestClient()
+ result = client.run(fun, args)
+ print "Results:", result