Skip to content

Instantly share code, notes, and snippets.

@andrewjennings
Created July 28, 2011 17:49
Show Gist options
  • Save andrewjennings/1112095 to your computer and use it in GitHub Desktop.
Save andrewjennings/1112095 to your computer and use it in GitHub Desktop.
Log request times
Index: views.py
===================================================================
--- views.py (revision 1402)
+++ views.py (working copy)
@@ -1143,6 +1143,8 @@
A JSON HttpResponse that contains the number of districts modified,
or an error message if adding fails.
"""
+ start = datetime.now()
+ sys.stderr.write('Received request at %s\n' % start)
note_session_activity(request)
status = { 'success': False }
@@ -1159,7 +1161,9 @@
version = plan.version
try:
+ start_geounit_add = datetime.now()
fixed = plan.add_geounits(districtid, geounit_ids, geolevel, version)
+ end_geounit_add = datetime.now()
status['success'] = True;
status['message'] = 'Updated %d districts' % fixed
status['updated'] = fixed
@@ -1173,6 +1177,8 @@
else:
status['message'] = 'Geounits weren\'t found in a district.'
+ end = datetime.now()
+ sys.stderr.write('Return result at %s; took %s total; %s for adding geounit\n' % (end, end - start, end_geounit_add - start_geounit_add))
return HttpResponse(json.dumps(status),mimetype='application/json')
@unique_session_or_json_redirect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment