├── LICENSE ├── MANIFEST.in ├── README.rst ├── example_project ├── __init__.py ├── dev.db ├── manage.py ├── settings.py ├── templates │ └── flatpages │ │ └── default.html └── urls.py ├── setup.py └── speedtracer ├── __init__.py └── middleware.py /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010 Chris Adams. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are 4 | permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of 7 | conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list 10 | of conditions and the following disclaimer in the documentation and/or other materials 11 | provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY Chris Adams ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 15 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Chris Adams OR 16 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 17 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 18 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 19 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 20 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 21 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | 23 | The views and conclusions contained in the software and documentation are those of the 24 | authors and should not be interpreted as representing official policies, either expressed 25 | or implied, of Chris Adams. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Django Speed Tracer 2 | =================== 3 | 4 | Simple performance monitoring for Django using Google Chrome's Speed Tracer 5 | 6 | Notes 7 | ----- 8 | 9 | Chrome Dev channel has not been stable with the Speed Tracer extension. If you 10 | don't see the server trace results or anything in the request/response headers 11 | you are probably running into this issue: 12 | 13 | http://code.google.com/p/speedtracer/issues/detail?id=28 14 | 15 | Installation 16 | ------------ 17 | 18 | #. Download and install Speed Tracer: 19 | 20 | http://code.google.com/webtoolkit/speedtracer/get-started.html 21 | 22 | #. Add ``"speedtracer"`` to your ``INSTALLED_APPS`` 23 | 24 | #. Add ``"speedtracer.middleware.SpeedTracerMiddleware"`` to the beginning of 25 | your ``MIDDLEWARE_CLASSES`` (this is important if you're also using projects like 26 | ``django-localeurl`` which alter normal URL routing) 27 | 28 | #. Load your page inside Chrome with SpeedTracer enabled 29 | 30 | #. Open SpeedTracer and expand the "Server Trace" in the page's detailed 31 | report which should look something like this: 32 | 33 | .. image:: http://farm5.static.flickr.com/4115/4815493734_4c20d6894f.jpg 34 | 35 | Example 36 | ------- 37 | 38 | There is a simple example project available in example_project which can 39 | be used to test the UI: 40 | 41 | #. Create a virtualenv 42 | #. Install django 43 | #. Change into example_project and run ``manage.py runserver`` 44 | -------------------------------------------------------------------------------- /example_project/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acdha/django-speedtracer/59a0f36d7b0add1326021e6e775d8f353c8438f3/example_project/__init__.py -------------------------------------------------------------------------------- /example_project/dev.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acdha/django-speedtracer/59a0f36d7b0add1326021e6e775d8f353c8438f3/example_project/dev.db -------------------------------------------------------------------------------- /example_project/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from django.core.management import execute_manager 3 | try: 4 | import settings # Assumed to be in the same directory. 5 | except ImportError: 6 | import sys 7 | sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) 8 | sys.exit(1) 9 | 10 | if __name__ == "__main__": 11 | execute_manager(settings) 12 | -------------------------------------------------------------------------------- /example_project/settings.py: -------------------------------------------------------------------------------- 1 | # Django settings for example_project project. 2 | import os 3 | 4 | DEBUG = True 5 | TEMPLATE_DEBUG = DEBUG 6 | 7 | ADMINS = ( 8 | # ('Your Name', 'your_email@domain.com'), 9 | ) 10 | 11 | MANAGERS = ADMINS 12 | 13 | DATABASES = { 14 | 'default': { 15 | 'ENGINE': 'django.db.backends.sqlite3', 16 | 'NAME': 'dev.db', 17 | 'USER': '', 18 | 'PASSWORD': '', 19 | 'HOST': '', 20 | 'PORT': '', 21 | } 22 | } 23 | 24 | # Local time zone for this installation. Choices can be found here: 25 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 26 | # although not all choices may be available on all operating systems. 27 | # On Unix systems, a value of None will cause Django to use the same 28 | # timezone as the operating system. 29 | # If running in a Windows environment this must be set to the same as your 30 | # system time zone. 31 | TIME_ZONE = 'America/Chicago' 32 | 33 | # Language code for this installation. All choices can be found here: 34 | # http://www.i18nguy.com/unicode/language-identifiers.html 35 | LANGUAGE_CODE = 'en-us' 36 | 37 | SITE_ID = 1 38 | 39 | # If you set this to False, Django will make some optimizations so as not 40 | # to load the internationalization machinery. 41 | USE_I18N = True 42 | 43 | # If you set this to False, Django will not format dates, numbers and 44 | # calendars according to the current locale 45 | USE_L10N = True 46 | 47 | # Absolute filesystem path to the directory that will hold user-uploaded files. 48 | # Example: "/home/media/media.lawrence.com/" 49 | MEDIA_ROOT = '' 50 | 51 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a 52 | # trailing slash if there is a path component (optional in other cases). 53 | # Examples: "http://media.lawrence.com", "http://example.com/media/" 54 | MEDIA_URL = '' 55 | 56 | # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a 57 | # trailing slash. 58 | # Examples: "http://foo.com/media/", "/media/". 59 | ADMIN_MEDIA_PREFIX = '/media/' 60 | 61 | # Make this unique, and don't share it with anybody. 62 | SECRET_KEY = '##g-qj0@4-@spjqp!#w2#(h^oag^9#wr3kzdji8m(ychwplvea' 63 | 64 | # List of callables that know how to import templates from various sources. 65 | TEMPLATE_LOADERS = ( 66 | 'django.template.loaders.filesystem.Loader', 67 | 'django.template.loaders.app_directories.Loader', 68 | # 'django.template.loaders.eggs.Loader', 69 | ) 70 | 71 | MIDDLEWARE_CLASSES = ( 72 | 'speedtracer.middleware.SpeedTracerMiddleware', 73 | 'django.middleware.common.CommonMiddleware', 74 | 'django.contrib.sessions.middleware.SessionMiddleware', 75 | 'django.middleware.csrf.CsrfViewMiddleware', 76 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 77 | 'django.contrib.messages.middleware.MessageMiddleware', 78 | 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 79 | ) 80 | 81 | ROOT_URLCONF = 'example_project.urls' 82 | 83 | TEMPLATE_DIRS = ( 84 | os.path.join(os.path.dirname(__file__), "templates"), 85 | ) 86 | 87 | INSTALLED_APPS = ( 88 | 'django.contrib.auth', 89 | 'django.contrib.contenttypes', 90 | 'django.contrib.sessions', 91 | 'django.contrib.sites', 92 | 'django.contrib.messages', 93 | 'django.contrib.admin', 94 | 'django.contrib.flatpages', 95 | 96 | 'speedtracer', 97 | ) 98 | -------------------------------------------------------------------------------- /example_project/templates/flatpages/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |