add profiling options
authorKali Kaneko (leap communications) <kali@leap.se>
Sun, 1 May 2016 18:28:18 +0000 (14:28 -0400)
committerKali Kaneko (leap communications) <kali@leap.se>
Sun, 1 May 2016 18:28:18 +0000 (14:28 -0400)
Makefile
server_with_soledad_syncer.py
soledad_sync.py

index aa881dc..52d7451 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,18 @@
 soledad-sync-server:
        twistd -n web --port 8080 --class=server_with_soledad_syncer.resource
 
+soledad-sync-server-lineprof:
+       kernprof -l server_with_soledad_syncer.py
+
+
 soledad-sync-server-debug:
        #twistd --profile=stats_obj --profiler=cProfile -n web --port 8080 --class=server_with_soledad_syncer.resource
        python -m cProfile -o sync.cprofile server_with_soledad_syncer.py 
 
+view-lineprofile:
+       python -m line_profiler server_with_soledad_syncer.py.lprof
+
+
 view-profile:
        cprofilev -f sync.cprofile
 
index 5346df6..bc61bb8 100755 (executable)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*- 
 #!/usr/bin/env python
 import os
 
index 710ecd5..44a90bd 100644 (file)
@@ -3,14 +3,16 @@ from leap.soledad.client.api import Soledad
 from twisted.internet import defer
 
 # EDIT THIS TO MATCH YOUR TEST ENVIRONMENT -------------
-UUID = 'deadbeef4'
-#HOST = 'http://futeisha:2323'
+UUID = 'deadbeef10'
+# HOST = 'http://futeisha:2323'
 HOST = 'http://localhost:2323'
-#NUM_DOCS = 100
-NUM_DOCS = 5
+# NUM_DOCS = 100
+NUM_DOCS = 50
 PAYLOAD = '/tmp/payload'
 # ------------------------------------------------------
 
+DO_THESEUS = os.environ.get('THESEUS', False)
+
 
 def _get_soledad_instance_from_uuid(uuid, passphrase, basedir, server_url,
                                     cert_file, token):
@@ -37,6 +39,11 @@ def upload_soledad_stuff():
     with open(PAYLOAD, 'r') as f:
         payload = f.read()
 
+    if DO_THESEUS:
+        from theseus import Tracer
+        t = Tracer()
+        t.install()
+
     s = _get_soledad_instance_from_uuid(
         UUID, 'pass', '/tmp/soledadsync', HOST, '', '')
 
@@ -45,12 +52,22 @@ def upload_soledad_stuff():
         d.addCallback(onSyncDone)
         return d
 
+    def stop_tracing(_):
+        if DO_THESEUS:
+            with open('callgrind.theseus', 'wb') as outfile:
+                t.write_data(outfile)
+            print "STOPPED TRACING, DUMPED IN CALLGRIND.THESEUS<<<<"
+
     cd = []
     for i in range(NUM_DOCS):
         cd.append(s.create_doc({'payload': payload}))
     d1 = defer.gatherResults(cd)
 
+
+
     # XXX comment out to nuke out the actual sync
-    d1.addCallback(do_sync)
+    #d1.addCallback(do_sync)
+    d1.addCallback(stop_tracing)
+
 
     return d1