From 9830bd00964a1c83cfc92151446adda6f14fbc54 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 20 Oct 2015 15:31:09 -0300 Subject: [refactor] CouchDocument is now ServerDocument As SoledadBackend is intended to be database agnostic, a new generic document is now used instead of the old one made for CouchDB. The only attribute that really relates to couch was couch_rev, removed on this commit as it can be set on CouchDatabase implementation when needed. --- scripts/profiling/mail/mx.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts/profiling') diff --git a/scripts/profiling/mail/mx.py b/scripts/profiling/mail/mx.py index b6a1e5cf..55084a40 100644 --- a/scripts/profiling/mail/mx.py +++ b/scripts/profiling/mail/mx.py @@ -5,7 +5,7 @@ import timeit from leap.keymanager import openpgp -from leap.soledad.common.couch import CouchDocument +from leap.soledad.common.document import ServerDocument from leap.soledad.common.crypto import ( EncryptionSchemes, ENC_JSON_KEY, @@ -47,7 +47,7 @@ def get_enc_json(pubkey, message): def get_new_doc(enc_json): - doc = CouchDocument(doc_id=str(uuid.uuid4())) + doc = ServerDocument(doc_id=str(uuid.uuid4())) doc.content = { 'incoming': True, ENC_SCHEME_KEY: EncryptionSchemes.PUBKEY, @@ -71,6 +71,7 @@ def put_lots_of_messages(db, number): log("Populating database with %d encrypted messages... " % number, line_break=False) pubkey = get_pubkey() + def _put_one_message(): put_one_message(pubkey, db) time = timeit.timeit(_put_one_message, number=number) -- cgit v1.2.3 From 46678a7aecb98dbdc20846477c7f5110f3c63861 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 17 Nov 2015 12:54:25 -0400 Subject: [feat] add script to measure batch of uploads - Releases: 0.8.0 --- scripts/profiling/sync/benchmark-uploads.py | 60 +++++++++++++++++++++++++++++ scripts/profiling/sync/profile-sync.py | 11 ++++-- scripts/profiling/sync/sample | 7 ++++ 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100755 scripts/profiling/sync/benchmark-uploads.py create mode 100644 scripts/profiling/sync/sample (limited to 'scripts/profiling') diff --git a/scripts/profiling/sync/benchmark-uploads.py b/scripts/profiling/sync/benchmark-uploads.py new file mode 100755 index 00000000..d371bb1a --- /dev/null +++ b/scripts/profiling/sync/benchmark-uploads.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# benchmark_uploads.py +# Copyright (C) 2015 LEAP +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +""" +Run benchmarks for sync (uploads). +""" +import getpass +import sys +import datetime +import subprocess + +NUM_ITER = 10 +NUM_UPLOADS = 10 + +RESULTS = [] + + +if __name__ == "__main__": + user = sys.argv[1] + passwd = sys.argv[2] + opts = ("--no-stats --send-num %s --payload-file sample --repeat-payload -p " + "%s -b /tmp/profile-soledad-upload ") % (NUM_UPLOADS, passwd) + + for i in xrange(NUM_ITER): + print "[+] ITERATION NUMBER: ", i + start = datetime.datetime.now() + cmd = "./profile-sync.py " + opts + user + print "CALLING", cmd + result = subprocess.check_call(cmd.split()) + print "EXIT CODE:", result + end = datetime.datetime.now() + delta = (end - start) + RESULTS.append(delta) + print "[+] SYNC TOOK %s seconds" % delta.seconds + + import numpy + res = [x.seconds for x in RESULTS] + print "-------------------------" + print "SYNC UPLOAD REPORT" + print "USER:", user + print "UPLOADS: %s 1K DOCS" % NUM_UPLOADS + print "ITERATIONS: %s" % NUM_ITER + print + print "mean :", numpy.mean(res) + print "stdev:", numpy.std(res) + print "-------------------------" diff --git a/scripts/profiling/sync/profile-sync.py b/scripts/profiling/sync/profile-sync.py index 9ef2ea92..8c18bde8 100755 --- a/scripts/profiling/sync/profile-sync.py +++ b/scripts/profiling/sync/profile-sync.py @@ -57,15 +57,17 @@ def create_docs(soledad, args): bail('--payload-file does not exist!') return - numdocs = args.send_num - docsize = args.send_size + numdocs = int(args.send_num) + docsize = int(args.send_size) # XXX this will FAIL if the payload source is smaller to size * num # XXX could use a cycle iterator with open(sample_path, "r+b") as sample_f: fmap = mmap.mmap(sample_f.fileno(), 0, prot=mmap.PROT_READ) + payload = fmap.read(docsize * 1024) for index in xrange(numdocs): - payload = fmap.read(docsize * 1024) + if not args.repeat_payload: + payload = fmap.read(docsize * 1024) s.create_doc({payload: payload}) # main program @@ -94,6 +96,9 @@ if __name__ == '__main__': parser.add_argument( '--send-num', dest='send_num', default=10, help='number of docs to send (default: 10)') + parser.add_argument( + '--repeat-payload', dest='repeat_payload', action='store_true', + default=False) parser.add_argument( '--payload-file', dest="payload_f", default=None, help='path to a sample file to use for the payloads') diff --git a/scripts/profiling/sync/sample b/scripts/profiling/sync/sample new file mode 100644 index 00000000..7b8fc8fa --- /dev/null +++ b/scripts/profiling/sync/sample @@ -0,0 +1,7 @@ + CAOS NUNCA MURIO. Bloque primordial sin esculpir, único excelentísimo monstruo, inerte y espontáneo, más ultravioleta que ninguna ideología (como las sombras antes de Babilonia), la homogénea unidad original del ser todavía irradia serena como los negros pendones de los Asesinos, perpetua y azarosamente ebria. + + Caos precede a todo principio de orden y entropía, no es ni Dios ni gusano, sus deseos insensatos abarcan y definen toda posible coreografía, todo éter y flogisto sin sentido: sus máscaras son cristalizaciones de su propia falta de rostro, como las nubes. + + Todo en la naturaleza es perfectamente real incluyendo la conciencia, no hay absolutamente nada de lo que preocuparse. No sólo se han roto las cadenas de la Ley, es que nunca existieron; los demonios nunca guardaron las estrellas, el Imperio jamás se fundó, a Eros nunca le creció la barba. + +No, escucha, lo que ocurrió fue esto: te mintieron, te vendieron ideas sobre el bien y el mal -- cgit v1.2.3