[cfe-commits] r101327 - in /cfe/trunk/utils/CIndex: ./ completion_logger_server.py

Ted Kremenek kremenek at apple.com
Wed Apr 14 18:02:31 PDT 2010


Author: kremenek
Date: Wed Apr 14 20:02:31 2010
New Revision: 101327

URL: http://llvm.org/viewvc/llvm-project?rev=101327&view=rev
Log:
Add simple python server for recording code completion timings.

Added:
    cfe/trunk/utils/CIndex/
    cfe/trunk/utils/CIndex/completion_logger_server.py   (with props)

Added: cfe/trunk/utils/CIndex/completion_logger_server.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/CIndex/completion_logger_server.py?rev=101327&view=auto
==============================================================================
--- cfe/trunk/utils/CIndex/completion_logger_server.py (added)
+++ cfe/trunk/utils/CIndex/completion_logger_server.py Wed Apr 14 20:02:31 2010
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+import sys
+from socket import *
+from time import localtime, strftime
+
+def main():
+  if len(sys.argv) < 4:
+    print "completion_logger_server.py <listen address> <listen port> <log file>"
+    exit(1)
+
+  host = sys.argv[1]
+  port = int(sys.argv[2])
+  buf = 1024 * 8
+  addr = (host,port)
+  
+  # Create socket and bind to address
+  UDPSock = socket(AF_INET,SOCK_DGRAM)
+  UDPSock.bind(addr)
+  
+  print "Listing on {0}:{1} and logging to '{2}'".format(host, port, sys.argv[3])
+
+  # Open the logging file.
+  f = open(sys.argv[3], "a")
+
+  # Receive messages
+  while 1:
+    data,addr = UDPSock.recvfrom(buf)
+    if not data:
+      break
+    else:
+      f.write(strftime("'%a, %d %b %Y %H:%M:%S' ", localtime()))
+      f.write(data)
+      f.write('\n')
+
+  # Close socket
+  UDPSock.close()
+
+if __name__ == '__main__':
+  main()

Propchange: cfe/trunk/utils/CIndex/completion_logger_server.py
------------------------------------------------------------------------------
    svn:executable = *





More information about the cfe-commits mailing list