Escape quotes as well - it's not always OK to leave them unquoted
[nepi.git] / tunbench.py
index 97daba7..9a3e6e7 100644 (file)
@@ -21,13 +21,22 @@ def rread(remote, maxlen, remote_fd = remote.fileno(), os_read=os.read):
     bytes += len(rv)
     return rv
 
-def test(cipher, passphrase, plr=None):
+def test(cipher, passphrase, plr=None, queuemodule=None):
    if plr:
         import random
         def accept(packet, direction, rng=random.random):
             return rng() > 0.5
    else:
         accept = None
+   if queuemodule:
+        import os, os.path
+        sys.path.append(os.path.join(
+            os.path.dirname(__file__), 
+            'src','nepi','testbeds','planetlab','scripts'))
+        queuemodule = __import__(queuemodule)
+        queueclass = queuemodule.queueclass
+   else:
+        queueclass = None
    TERMINATE = []
    def stopme():
        time.sleep(100)
@@ -35,7 +44,7 @@ def test(cipher, passphrase, plr=None):
    t = threading.Thread(target=stopme)
    t.start()
    tunchannel.tun_fwd(tun, remote, True, True, passphrase, True, TERMINATE, None, tunkqueue=500,
-        rwrite = rwrite, rread = rread, cipher=cipher,
+        rwrite = rwrite, rread = rread, cipher=cipher, queueclass=queueclass,
         accept_local = accept, accept_remote = accept)
 
 # Swallow exceptions on decryption
@@ -67,4 +76,11 @@ pstats.Stats('tunchannel.plr.profile').strip_dirs().sort_stats('time').print_sta
 
 print "Bandwidth (50%% PLR): %.4fMb/s" % ( bytes / 200.0 * 8 / 2**20, )
 
+bytes = 0
+cProfile.runctx('test(None,None,None,"tosqueue")',globals(),locals(),'tunchannel.tos.profile')
+
+print "Profile (TOS):"
+pstats.Stats('tunchannel.tos.profile').strip_dirs().sort_stats('time').print_stats()
+
+print "Bandwidth (TOS): %.4fMb/s" % ( bytes / 200.0 * 8 / 2**20, )