From ec9fec4fd18f0530828f13228a81bdafa72dbfe6 Mon Sep 17 00:00:00 2001 From: drebs Date: Sun, 1 May 2016 21:26:12 -0300 Subject: add phases --- get_client_cpu_mem.py | 4 ++-- graphit | 2 +- measure-perf-series.py | 8 ++++---- server_with_soledad_syncer.py | 10 ++++++++-- soledad_sync.py | 16 ++++++++++++---- 5 files changed, 27 insertions(+), 13 deletions(-) mode change 100755 => 100644 server_with_soledad_syncer.py 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 old mode 100755 new mode 100644 index dacaecb..3d495b6 --- 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 -- cgit v1.2.3