summaryrefslogtreecommitdiff
path: root/scripts/profiling/sync/benchmark-uploads.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/profiling/sync/benchmark-uploads.py')
-rwxr-xr-xscripts/profiling/sync/benchmark-uploads.py60
1 files changed, 60 insertions, 0 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 "-------------------------"