[pypy-svn] r80153 - in pypy/benchmarks: . own/twisted

fijal at codespeak.net fijal at codespeak.net
Sun Jan 2 15:59:51 CET 2011


Author: fijal
Date: Sun Jan  2 15:59:49 2011
New Revision: 80153

Modified:
   pypy/benchmarks/benchmarks.py
   pypy/benchmarks/own/twisted/web.py
Log:
Try to re-enable web.py from twisted-benchmarks-fixed-web by exarkun


Modified: pypy/benchmarks/benchmarks.py
==============================================================================
--- pypy/benchmarks/benchmarks.py	(original)
+++ pypy/benchmarks/benchmarks.py	Sun Jan  2 15:59:49 2011
@@ -49,11 +49,8 @@
              'spectral-norm', 'chaos', 'telco', 'go', 'pyflate-fast',
              'raytrace-simple', 'crypto_pyaes', 'waf', 'bm_mako']:
     _register_new_bm(name, name, globals(), **opts.get(name, {}))
-for name in ['names', 'iteration', 'tcp', 'pb']:#, 'accepts', 'web']:
-    if name == 'web':
-        iteration_scaling = 0.35
-    else:
-        iteration_scaling = 1.0
+for name in ['names', 'iteration', 'tcp', 'pb', 'web']:#, 'accepts']:
+    iteration_scaling = 1.0
     _register_new_bm_twisted(name, 'twisted_' + name,
                      globals(), bm_env={'PYTHONPATH': ':'.join(TWISTED)},
                                  iteration_scaling=iteration_scaling)

Modified: pypy/benchmarks/own/twisted/web.py
==============================================================================
--- pypy/benchmarks/own/twisted/web.py	(original)
+++ pypy/benchmarks/own/twisted/web.py	Sun Jan  2 15:59:49 2011
@@ -1,14 +1,14 @@
 
 """
-This benchmark runs a trivial Twisted Web server and client and makes as
-many requests as it can in a fixed period of time.
+This benchmark runs a trivial Twisted Web server and client and makes as many
+requests as it can in a fixed period of time.
 
-A significant problem with this benchmark is the lack of persistent
-connections in the HTTP client.  Lots of TCP connections means lots of
-overhead in the kernel that's not really what we're trying to benchmark. 
-Plus lots of sockets end up in TIME_WAIT which has a (briefly) persistent
-effect on system-wide performance and makes consecutive runs of the
-benchmark vary wildly in their results.
+A significant problem with this benchmark is the lack of persistent connections
+in the HTTP client.  Lots of TCP connections means lots of overhead in the
+kernel that's not really what we're trying to benchmark.  Plus lots of sockets
+end up in TIME_WAIT which has a (briefly) persistent effect on system-wide
+performance and makes consecutive runs of the benchmark vary wildly in their
+results.
 """
 
 from twisted.internet.protocol import Protocol
@@ -54,19 +54,30 @@
 
 
 
-interface = 0
 def main(reactor, duration):
-    global interface
+    interfaceCounter = int(reactor.seconds()) % 254 + 1
+
+    interface = '127.0.0.%d' % (interfaceCounter,)
+
     concurrency = 10
 
+    class BindLocalReactor(object):
+        def __init__(self, reactor):
+            self._reactor = reactor
+
+        def __getattr__(self, name):
+            return getattr(self._reactor, name)
+        
+        def connectTCP(self, host, port, factory, timeout=30, bindAddress=(interface, 0)):
+            return self._reactor.connectTCP(host, port, factory, timeout, bindAddress)
+
+
     root = Resource()
     root.putChild('', Data("Hello, world", "text/plain"))
 
-    interface += 1
-    interface %= 255
     port = reactor.listenTCP(
-        0, Site(root), backlog=128, interface='127.0.0.%d' % (interface,))
-    agent = Agent(reactor)
+        0, Site(root), backlog=128, interface=interface)
+    agent = Agent(BindLocalReactor(reactor))
     client = Client(reactor, port.getHost().host, port.getHost().port, agent)
     d = client.run(concurrency, duration)
     def cleanup(passthrough):



More information about the Pypy-commit mailing list