ericholscher / django-test-utils

Utilities for testing Django applications
http://django-test-utils.readthedocs.org/
MIT License
343 stars 69 forks source link

crawler: query count plugin #11

Closed acdha closed 14 years ago

acdha commented 14 years ago

This is a simple plugin which logs the number of database queries executed for a view. It's currently Django-1.2 only.

acdha commented 14 years ago

Ack, bitten by the github pull interface not updating to the commit range chosen. Will close.

acdha commented 14 years ago

Here's the single request to cherry pick - it doesn't look like there's any way to send a request which doesn't pull in everything else:

http://github.com/acdha/django-test-utils/commit/2b7e64535314f3e4743f28ab232a96139dd9e137

kmike commented 14 years ago

Hi all.

I wrote another hacky piece of code for this problem: http://gist.github.com/573536

Pros: can be used outside crawler as decorator or 'with' context manager. No TestCase subclass is needed. Cons: settings.DEBUG patching

Maybe it can be combined with acdha's code? What do you think?

acdha commented 14 years ago

There was a little bit of a discussion in IRC yesterday. My proposal:

  1. Split django-test-utils testmaker & crawler into separate projects
  2. Split most of the current crawler plugins into a library of decorator/context manager functions which stay in django-test-utils so anyone who wants to count queries, track memory, etc. can reuse them (it'd be great to coordinate with django-debug-toolbar as well); the remaining, much simpler plugins move with the rest of crawler.
  3. Start adding some extra data collectors - e.g. I'd like to come up with one good profile replacement for both http://github.com/acdha/django-sugar/blob/master/sugar/middleware/speedtracer.py (using sys.settrace) and the cProfile-based code which the debug_toolbar community is working on for very similar needs.
ericholscher commented 14 years ago

These sound like good ideas. Let's get together with Rob at the sprints today and talk about this :) (Sprints FTW)