diff options
author | Kali Kaneko <kali@leap.se> | 2015-11-17 12:54:25 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-11-17 12:56:26 -0400 |
commit | 46678a7aecb98dbdc20846477c7f5110f3c63861 (patch) | |
tree | 6d33b00719b8bf85d92a43fd6ca0ac11dffc0eb0 | |
parent | 3aea1652d82755affdcf4c734f9f0ba004482046 (diff) |
[feat] add script to measure batch of uploads
- Releases: 0.8.0
-rwxr-xr-x | scripts/profiling/sync/benchmark-uploads.py | 60 | ||||
-rwxr-xr-x | scripts/profiling/sync/profile-sync.py | 11 | ||||
-rw-r--r-- | scripts/profiling/sync/sample | 7 |
3 files changed, 75 insertions, 3 deletions
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 <http://www.gnu.org/licenses/>. +""" +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 @@ -95,6 +97,9 @@ if __name__ == '__main__': '--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') parser.add_argument( 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 |