From 03204fa4eede348ded4a0e860163a7632a44a5de Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Wed, 28 Mar 2018 21:06:45 +0200
Subject: [PATCH] Add Silk profiler

---
 SciPost_v1/settings/base.py | 12 +++++-
 SciPost_v1/urls.py          |  1 +
 requirements.txt            | 82 ++++++++++++++++++-------------------
 3 files changed, 52 insertions(+), 43 deletions(-)

diff --git a/SciPost_v1/settings/base.py b/SciPost_v1/settings/base.py
index cfa3afb43..e053358dd 100644
--- a/SciPost_v1/settings/base.py
+++ b/SciPost_v1/settings/base.py
@@ -106,6 +106,7 @@ INSTALLED_APPS = (
     'stats',
     'petitions',
     'webpack_loader',
+    'silk',
 )
 
 
@@ -155,6 +156,7 @@ MATHJAX_CONFIG_DATA = {
     }
 
 MIDDLEWARE = (
+    'silk.middleware.SilkyMiddleware',
     # 'django.middleware.http.ConditionalGetMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.locale.LocaleMiddleware',
@@ -164,9 +166,17 @@ MIDDLEWARE = (
     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
-    'django.middleware.security.SecurityMiddleware'
+    'django.middleware.security.SecurityMiddleware',
 )
 
+SILKY_PYTHON_PROFILER = True
+SILKY_PYTHON_PROFILE_BINARY = False
+SILKY_AUTHENTICATION = True
+SILKY_AUTHORIZATION = True
+SILKY_META = True
+SILKY_INTERCEPT_PERCENT = 100
+SILKY_MAX_RECORDED_REQUESTS = 10**4
+
 ROOT_URLCONF = 'SciPost_v1.urls'
 
 TEMPLATES = [
diff --git a/SciPost_v1/urls.py b/SciPost_v1/urls.py
index 2fe82bebd..48f75f7c0 100644
--- a/SciPost_v1/urls.py
+++ b/SciPost_v1/urls.py
@@ -53,6 +53,7 @@ urlpatterns = [
     url(r'^stats/', include('stats.urls', namespace="stats")),
     # Keep temporarily for historical reasons
     url(r'^supporting_partners/', include('partners.urls', namespace="_partners")),
+    url(r'^silk/', include('silk.urls', namespace='silk')),
 ]
 
 if settings.DEBUG:
diff --git a/requirements.txt b/requirements.txt
index 1e0972f07..4d4f1e567 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,57 +1,55 @@
-# Core
-argon2-cffi==16.3.0  # Password hashing algorithm
-Babel==2.4
+alabaster==0.7.10
+argon2-cffi==16.3.0
+autopep8==1.3.4
+Babel==2.4.0
+certifi==2017.7.27.1
+cffi==1.10.0
+chardet==3.0.4
 Django==1.11.4
-feedparser==5.2.1   # Check: not updated since 2016
-psycopg2==2.7.3  # PostgreSQL engine
-pytz==2017.2  # Timezone package
-djangorestframework==3.6.3
-requests==2.18.3
-
-
-# Django packages
-django_ajax_selects==1.6
+django-ajax-selects==1.6.0
 django-countries==4.6.1
+django-crispy-forms==1.6.1
 django-debug-toolbar==1.8
 django-extensions==1.7.6
 django-filter==1.0.4
 django-guardian==1.4.9
-django-mathjax==0.0.5  # This thing looks dead as well
-django-mptt==0.8.6  # Dead
-django-sphinxdoc==1.5.1
+django-haystack==2.5.1
+django-mathjax==0.0.5
+django-mptt==0.8.6
 django-recaptcha==1.3.1
-django-webpack-loader==0.5
-
-
-# Documentation Packages
-docutils==0.12  # What's this thing?
-Pygments==2.2.0  # Syntax highlighter
-Sphinx==1.4.9
-sphinx-rtd-theme==0.1.9  # Sphinx theme
-
-
-# Testing
+django-silk==2.0.0
+django-simple-captcha==0.5.3
+django-sphinxdoc==1.5.1
+django-webpack-loader==0.5.0
+djangorestframework==3.6.3
+docutils==0.12
 factory-boy==2.10.0
+fake-factory==0.7.2
 Faker==0.8.12
-
-
-# Django Utils
-django-haystack==2.5.1  # Check if this is really used. Package is not up-to-date
-Whoosh==2.7.4  # Directly related to Haystack.
-
-
-# Python Utils
-ithenticate-api-python==0.7
-mailchimp3==2.0.15
-python-dateutil==2.6.0  # Doesn't Django have this functionality built-in?  -- JdW
-Pillow==3.4.2  # Latest version is v4.2.1; need to know about usage before upgrade. -- JdW
-html2text
-
-# Possibly dead (most probably not used anymore and possibly not up-to-date packages)  -- JdW (August 15th, 2017)
+feedparser==5.2.1
+gprof2dot==2016.10.13
+html2text==2017.10.4
+idna==2.5
 imagesize==0.7.1
+ithenticate-api-python==0.7
 Jinja2==2.8
+mailchimp3==2.0.15
 Markdown==2.6.7
 MarkupSafe==0.23
-pep8==1.7.0  # Is someone using this?
+pep8==1.7.0
+Pillow==3.4.2
+psycopg2==2.7.3
+pycodestyle==2.3.1
+pycparser==2.17
+Pygments==2.2.0
+python-dateutil==2.6.0
+pytz==2017.2
+requests==2.18.3
 six==1.10.0
 snowballstemmer==1.2.1
+Sphinx==1.4.9
+sphinx-rtd-theme==0.1.9
+sqlparse==0.2.3
+text-unidecode==1.2
+urllib3==1.22
+Whoosh==2.7.4
-- 
GitLab