Registry / testing / django-perf-rec

django-perf-rec

JSON →
library4.31.0pypypi✓ verified 84d ago

A Django library for recording and asserting performance characteristics of your code over time. It provides a Python context manager and Django test case mixin to record per-request SQL query counts and durations, template node counts, and response sizes. Version 4.31.0 supports Python 3.9+ and Django 3.2+. The project is actively maintained with a regular release cadence.

pip install django-perf-rec
INSTALL
IMPORT
SIG · DJANGO-PERF-REC
D
django-perf-rec
testingpythonv4.31.0
Install
3.7s avg
Import
Disk
68MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.31.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 68.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.7s · import 0.000s · 70MB
68MB installed
● package 68MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TestCaseMixin
from django_perf_rec import TestCaseMixin
from django_perf_rec import RecordRequestsMixin

Basic usage with RecordRequestsMixin to automatically record and assert database query counts and templates.

from django_perf_rec import RecordRequestsMixin from django.test import TestCase class MyTestCase(RecordRequestsMixin, TestCase): def test_view(self): response = self.client.get('/') self.assertNumQueries(5) # autmoatically records baseline self.assertTemplateUsed('index.html')
Debug
Known issues
gotchaRecordRequestsMixin must be listed before TestCase in the base class order to work correctly.
fix
Ensure mixin order: class MyTestCase(RecordRequestsMixin, TestCase):
affects: all
breakingIn version 4.0.0, the record() context manager was removed. Use the RecordRequestsMixin or record_requests() instead.
fix
Upgrade to use RecordRequestsMixin for test classes or record_requests() for context managers.
affects: >=4.0.0
deprecatedThe attribute 'assertNumQueries' is deprecated in favor of 'assertNumQueries' but may be removed in a future version.
fix
Use assertNumQueries with the same signature.
affects: >=4.0.0
Upgrade
Version history
4.31.0latest on PyPI · released Sep 18, 2025
Audit
Dependencies
djangorequiredRuntime dependency for Django integration
Agent activity
19 hits · last 30 days
node
18
Resources
django-perf-rec — pip install django-perf-rec · libregistry