Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add simple benchmark file with funkload

Roland Geider606d8b299465
diff --git a/extras/bench/README.txt b/extras/bench/README.txt
new file mode 100644
index 000000000..69907e0a3
--- /dev/null
+++ b/extras/bench/README.txt
@@ -0,0 +1,41 @@
+====================
+Simple funkLoad test
+====================
+
+This is a simple funkLoad testcase.
+
+You need to install funkload (can be done e.g. with pip) and gnuplot (via your
+package manager) if you want to create plots. It requires an running web test
+server.
+
+WARNING: You should *not* run this script against a server that is not under
+your responsablity as it can result a DOS in bench mode.
+
+For more information on configuration, options, etc. refer to the funkload
+documentation page: http://funkload.nuxeo.org
+
+
+
+Instruction
+-----------
+
+1/ Bench it
+
+ Bench it with few cycles::
+
+ fl-run-bench test_Simple.py Simple.test_simple
+
+ Note that for correct interpretation you should run the FunkLoad bencher
+ in a different host than the server, the server should be 100% dedicated
+ to the application.
+
+ If you want to bench with more than 200 users, you need to reduce the
+ default stack size used by a thread, for example try a `ulimit -s 2048`
+ before running the bench.
+
+ Performance limits are hit by FunkLoad before apache's limit is reached,
+ since it uses significant CPU resources.
+
+2/ Build the report::
+
+ fl-build-report --html simple-bench.xml
diff --git a/extras/bench/Simple.conf b/extras/bench/Simple.conf
new file mode 100644
index 000000000..6fe610dca
--- /dev/null
+++ b/extras/bench/Simple.conf
@@ -0,0 +1,52 @@
+# FunkLoad test configuration file
+
+# ------------------------------------------------------------
+# Main section
+#
+[main]
+title=Simple FunkLoad tests
+description=Simply testing a default static page
+
+# the server to test
+url=http://localhost:8000
+
+
+# ------------------------------------------------------------
+# Tests description and configuration
+#
+[test_simple]
+description=Access some pages
+
+
+# ------------------------------------------------------------
+# Configuration for bench mode fl-run-bench
+#
+[bench]
+
+# cycles = list of cycles with their number of concurrent users
+cycles = 1:5:10:15:20:30
+
+# duration = duration of a cycle in seconds
+duration = 10
+
+# startup_delay = time to wait between starting-up threads in seconds
+startup_delay = 0.01
+
+# sleep_time = time to wait between test in seconds
+sleep_time = 0.01
+
+# cycle_time = time to wait between cycle in seconds
+cycle_time = 1
+
+# same keys than in [ftest] section
+log_to =
+log_path = simple-bench.log
+result_path = simple-bench.xml
+#ok_codes = 200:301:302
+sleep_time_min = 0
+sleep_time_max = 0.5
+
+[distribute]
+log_path = log-distributed
+funkload_location=http://pypi.python.org/packages/source/f/funkload/funkload-1.16.1.tar.gz
+
diff --git a/extras/bench/test_Simple.py b/extras/bench/test_Simple.py
new file mode 100644
index 000000000..b9957669b
--- /dev/null
+++ b/extras/bench/test_Simple.py
@@ -0,0 +1,34 @@
+# -*- coding: iso-8859-15 -*-
+'''
+Simple FunkLoad test
+'''
+import unittest
+from random import random
+from funkload.FunkLoadTestCase import FunkLoadTestCase
+
+class Simple(FunkLoadTestCase):
+ '''
+ This test uses the configuration file Simple.conf.
+ '''
+
+ def setUp(self):
+ '''
+ Setting up test.
+ '''
+ self.server_url = self.conf_get('main', 'url')
+
+ def test_simple(self):
+ # The description should be set in the configuration file
+ server_url = self.server_url
+
+ # Exercises
+ self.get(server_url + '/en/exercise/overview/', description='Get exercise overview')
+ self.get(server_url + '/en/exercise/muscle/overview/', description='Get muscle overview')
+ self.get(server_url + '/de/de/exercise/79/view/', description='Get exercise page')
+
+ # Nutrition
+ self.get(server_url + '/de/nutrition/ingredient/overview/', description='Get ingredient overview')
+
+
+if __name__ in ('main', '__main__'):
+ unittest.main()