소스 검색

Add scripts which I've been using as performance test fixtures.

Chris McDonough 18 년 전
부모
커밋
aa3314288c
2개의 변경된 파일88개의 추가작업 그리고 0개의 파일을 삭제
  1. 48 0
      src/supervisor/scripts/loop_eventgen.py
  2. 40 0
      src/supervisor/scripts/loop_listener.py

+ 48 - 0
src/supervisor/scripts/loop_eventgen.py

@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+##############################################################################
+#
+# Copyright (c) 2007 Agendaless Consulting and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+# A process which emits a process communications event on its stdout,
+# and subsequently waits for a line to be sent back to its stdin by
+# loop_listener.py.
+
+import sys
+import time
+from supervisor import childutils
+
+def main(max):
+    start = time.time()
+    report = open('/tmp/report', 'w')
+    i = 0
+    while 1:
+        childutils.write_stdout('<!--XSUPERVISOR:BEGIN-->')
+        childutils.write_stdout('the data')
+        childutils.write_stdout('<!--XSUPERVISOR:END-->')
+        data = sys.stdin.readline()
+        report.write(str(i) + ' @ %s\n' % childutils.get_asctime())
+        report.flush()
+        i+=1
+        if max and i >= max:
+            end = time.time()
+            report.write('%s per second\n' % (i / (end - start)))
+            sys.exit(0)
+
+if __name__ == '__main__':
+    max = 0
+    if len(sys.argv) > 1:
+        max = int(sys.argv[1])
+    main(max)
+        
+

+ 40 - 0
src/supervisor/scripts/loop_listener.py

@@ -0,0 +1,40 @@
+#!/usr/bin/env python -u
+
+##############################################################################
+#
+# Copyright (c) 2007 Agendaless Consulting and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+# An event listener that listens for process communications events
+# from loop_eventgen.py and uses RPC to write data to the event
+# generator's stdin.
+
+import sys
+import os
+from supervisor import childutils
+
+def main():
+    rpcinterface = childutils.getRPCInterface(os.environ)
+    while 1:
+        childutils.write_stdout('READY\n')
+        line = sys.stdin.readline()
+        headers = childutils.get_headers(line)
+        payload = sys.stdin.read(int(headers['len']))
+        if headers['eventname'].startswith('PROCESS_COMMUNICATION'):
+            pheaderinfo, pdata = payload.split('\n')
+            pheaders = childutils.get_headers(pheaderinfo)
+            pname = '%s:%s' % (pheaders['processname'], pheaders['groupname'])
+            rpcinterface.supervisor.sendProcessStdin(pname, 'Got it yo\n')
+        childutils.write_stdout('OK\n')
+
+if __name__ == '__main__':
+    main()