Login

Tag "cprofile"

Snippet List

Unit Test Profiling for Django 1.3/1.4

The snippet is a modification of [snippet 1315](http://djangosnippets.org/snippets/1315/) to fit the needs for Django 1.3 and 1.4. You can follow the explanations and instructions there. To plot a nice and so useful call-graph with timings, call: $ gprof2dot -f pstats unittest.profile | dot -Tpng -o unittest.profile.graph.png where 'unittest.profile' is the test runners profile output defined in your settings.

  • profile
  • unittest
  • runtime
  • cprofile
Read More

Unit Test Profiling

A test runner for Django unittests which profiles the tests run, and saves the result. Very useful for diagnosing your apps. Place the top portion of the code into a file called `profiling.py` someplace in your python path. Update your `settings.py` file with the bottom two lines of the code. Now you are ready, so just run `python manage.py test [appnames...]` to test any apps listed with profiling. By default this will just print a nice report after the unittests. If you change the value of `TEST_PROFILE` to a file, the profile will be saved to that file. The latter is recommended because these profiling reports have a lot of info in them, so it is best to tear through them with the `pstats` module.

  • profile
  • unittest
  • cprofile
Read More

2 snippets posted so far.