summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-05-01 14:28:18 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2016-05-01 14:28:18 -0400
commitbd113c72a3a37c91806dd2cbf0cf8fd47949a2f4 (patch)
tree1997a6abd66dc5c580d8dc64a26846f3c149d5a9
parent7595e5f951470632ca8fb2389f9125053d11cf92 (diff)
add profiling options
-rw-r--r--Makefile8
-rwxr-xr-xserver_with_soledad_syncer.py1
-rw-r--r--soledad_sync.py27
3 files changed, 31 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index aa881dc..52d7451 100644
--- 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
diff --git a/server_with_soledad_syncer.py b/server_with_soledad_syncer.py
index 5346df6..bc61bb8 100755
--- a/server_with_soledad_syncer.py
+++ b/server_with_soledad_syncer.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
#!/usr/bin/env python
import os
diff --git a/soledad_sync.py b/soledad_sync.py
index 710ecd5..44a90bd 100644
--- a/soledad_sync.py
+++ b/soledad_sync.py
@@ -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