summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2016-05-01 21:26:12 -0300
committerdrebs <drebs@riseup.net>2016-05-01 21:50:44 -0300
commitec9fec4fd18f0530828f13228a81bdafa72dbfe6 (patch)
tree0252031a5c37b731cc4cfeb1958f6534925cc5bc
parenta4b80ff24950b927fa30baa9996609ee13e47c83 (diff)
add phases
-rw-r--r--get_client_cpu_mem.py4
-rwxr-xr-xgraphit2
-rw-r--r--measure-perf-series.py8
-rw-r--r--[-rwxr-xr-x]server_with_soledad_syncer.py10
-rw-r--r--soledad_sync.py16
5 files changed, 27 insertions, 13 deletions
diff --git a/get_client_cpu_mem.py b/get_client_cpu_mem.py
index ba5049a..fe1aeec 100644
--- a/get_client_cpu_mem.py
+++ b/get_client_cpu_mem.py
@@ -2,10 +2,10 @@ import commands
import urllib
import psutil
-pid = urllib.urlopen('http://localhost:8080/pid').read()
+pid, phase = urllib.urlopen('http://localhost:8080/stats').read().split()
res = commands.getoutput("ps -p " + pid + " -o \%cpu,\%mem")
splitted = res.split()
cpu = splitted[2]
mem = splitted[3]
-print cpu, mem
+print cpu, mem, phase
diff --git a/graphit b/graphit
index 92ea0e7..0c809c0 100755
--- a/graphit
+++ b/graphit
@@ -5,5 +5,5 @@ set title filename
set key outside
#plot name with linespoints notitle
#plot filename using 1:2 with linespoints title columnheader
-plot for [col=2:4] filename using 1:col with linespoints title columnheader
+plot for [col=2:5] filename using 1:col with linespoints title columnheader
pause -1
diff --git a/measure-perf-series.py b/measure-perf-series.py
index 2c17ce7..5694bc8 100644
--- a/measure-perf-series.py
+++ b/measure-perf-series.py
@@ -6,15 +6,15 @@ import datetime
# you have significant variability in there.
POINTS = 200
-commands.getoutput('echo time req/s cpu mem > series.log')
+commands.getoutput('echo time req/s cpu mem phase > series.log')
start = datetime.datetime.now()
for i in range(POINTS):
value = commands.getoutput('python get_ping_rate.py')
print "Step", i, "...", value
- cpu_mem = commands.getoutput('python get_client_cpu_mem.py')
- cpu, mem = cpu_mem.split()
+ stats = commands.getoutput('python get_client_cpu_mem.py')
+ cpu, mem, phase = stats.split()
now = datetime.datetime.now()
secs = (now - start).total_seconds()
commands.getoutput(
- 'echo %s\t%s\t%s\t%s >> series.log' % (secs, value, cpu, mem))
+ 'echo %s\t%s\t%s\t%s\t%s >> series.log' % (secs, value, cpu, mem, phase))
diff --git a/server_with_soledad_syncer.py b/server_with_soledad_syncer.py
index dacaecb..3d495b6 100755..100644
--- a/server_with_soledad_syncer.py
+++ b/server_with_soledad_syncer.py
@@ -3,10 +3,11 @@
import os
+import datetime
from klein import run, route, resource
-import soledad_sync as sync
from twisted.internet import reactor
-import datetime
+
+import soledad_sync as sync
@route('/start-sync')
@@ -31,6 +32,11 @@ def stop(request):
reactor.callLater(1, reactor.stop)
return ''
+@route('/stats')
+def stats(request):
+ pid = os.getpid()
+ return "%d %d" % (pid, sync.phase * 50)
+
if __name__ == "__main__":
run("localhost", 8080)
diff --git a/soledad_sync.py b/soledad_sync.py
index deadc56..acb46cf 100644
--- a/soledad_sync.py
+++ b/soledad_sync.py
@@ -15,6 +15,8 @@ PAYLOAD = '/tmp/payload'
DO_THESEUS = os.environ.get('THESEUS', False)
+phase = 0
+
def _get_soledad_instance_from_uuid(uuid, passphrase, basedir, server_url,
cert_file, token):
secrets_path = os.path.join(basedir, '%s.secret' % uuid)
@@ -32,10 +34,14 @@ def _get_soledad_instance_from_uuid(uuid, passphrase, basedir, server_url,
def onSyncDone(result):
+ #-------- PHASE 3: sync done.
+ global phase
+ phase += 1
print "SYNC DONE!", result
def upload_soledad_stuff():
+ global phase
with open(PAYLOAD, 'r') as f:
payload = f.read()
@@ -49,6 +55,9 @@ def upload_soledad_stuff():
UUID, 'pass', '/tmp/soledadsync', HOST, '', 'an-auth-token')
def do_sync(_):
+ global phase
+ #-------- PHASE 2: docs created, defer sync
+ phase += 1
d = s.sync()
d.addCallback(onSyncDone)
return d
@@ -60,15 +69,14 @@ def upload_soledad_stuff():
print "STOPPED TRACING, DUMPED IN CALLGRIND.THESEUS<<<<"
cd = []
+ #-------- PHASE 1: deferring doc creation
+ phase += 1
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