Tests / apps/projects/tests.py
SlugsAndNumbersTest::test_upsert_keeps_slugs_and_makes_them_unique
First seen 8 hours ago in 78a4357
CI
github-actions:test
5 runs
Average
13 ms
median 14 ms
max 17 ms
max 17 ms
Phases
Setup 0.69 ms
Call 12 ms
Teardown 0.87 ms
Categories
Database 10 ms
Other (Unsampled, pytest, Deep copies) 3 ms
16 database queries per run
Needs 0 KB of memory (max 0 KB)
Duration per run
Where the time goes
Latest run in ci:github-actions:test, 48 minutes ago ·
open run
setup0.86 ms6.3%
call12 ms89.2%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:1441 tests = Test.objects.upsert(self.project, ["tests/test_a.py::test_x[a b]", "tests/test_a.py::test_x[a-b]"])7 ms51.0%
TestData.__get__django/test/testcases.py:13672 ms12.7%
deepcopy<stdlib>/copy.py:1572 ms12.7%
_reconstruct<stdlib>/copy.py:2552 ms12.7%
deepcopy<stdlib>/copy.py:1252 ms12.7%
_deepcopy_dict<stdlib>/copy.py:2022 ms12.7%
TestManager.upsertapps/projects/models.py:2292 ms12.7%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms12.7%
QuerySet.__iter__django/db/models/query.py:3902 ms12.7%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms12.7%
ValuesListIterable.__iter__django/db/models/query.py:2382 ms12.7%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms12.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
TestManager.upsertapps/projects/models.py:230 self.bulk_create( # sorted, so uploads sharing tests lock their rows in the same order2 ms12.7%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms12.7%
QuerySet.bulk_createdjango/db/models/query.py:8332 ms12.7%
QuerySet._batched_insertdjango/db/models/query.py:19562 ms12.7%
QuerySet._insertdjango/db/models/query.py:19182 ms12.7%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19252 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
TestManager.upsertapps/projects/models.py:236 return {test.name: test for test in self.filter(project=project, name__in=names)}2 ms12.7%
QuerySet.__iter__django/db/models/query.py:3902 ms12.7%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms12.7%
ModelIterable.__iter__django/db/models/query.py:952 ms12.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:14452 ms12.7%
TestManager.upsertapps/projects/models.py:2292 ms12.7%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms12.7%
QuerySet.__iter__django/db/models/query.py:3902 ms12.7%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms12.7%
ValuesListIterable.__iter__django/db/models/query.py:2382 ms12.7%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms12.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_uniqueapps/projects/tests.py:14472 ms12.7%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms12.7%
QuerySet.createdjango/db/models/query.py:6692 ms12.7%
Test.saveapps/projects/models.py:2932 ms12.7%
TestManager.slugs_forapps/projects/models.py:240 existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))2 ms12.7%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms12.7%
QuerySet.filterdjango/db/models/query.py:15422 ms12.7%
QuerySet._filter_or_excludedjango/db/models/query.py:15602 ms12.7%
QuerySet._filter_or_exclude_inplacedjango/db/models/query.py:15702 ms12.7%
Query.add_qdjango/db/models/sql/query.py:16712 ms12.7%
Query._add_qdjango/db/models/sql/query.py:17032 ms12.7%
Query.build_filterdjango/db/models/sql/query.py:15602 ms12.7%
TransactionTestCase._post_teardowndjango/test/testcases.py:1240 self._fixture_teardown()2 ms12.7%
TestCase._fixture_teardowndjango/test/testcases.py:14952 ms12.7%
DatabaseWrapper.check_constraintsdjango/db/backends/postgresql/base.py:4842 ms12.7%
CursorWrapper.executedjango/db/backends/utils.py:792 ms12.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms12.7%
CursorWrapper._executedjango/db/backends/utils.py:1032 ms12.7%
Cursor.executepsycopg/cursor.py:1132 ms12.7%
Connection.waitpsycopg/connection.py:4952 ms12.7%
Estimated from 8 samples; phase durations are exact. Frames from pytest and pluggy are
hidden
.
Hot lines in your code
|
apps/projects/models.py:240
existing = dict(self.filter(project_id=project_id, name__in=names).values_list("name", "slug"))
TestManager.slugs_for
· Database
|
5 ms |
|
apps/projects/tests.py:1441
tests = Test.objects.upsert(self.project, ["tests/test_a.py::test_x[a b]", "tests/test_a.py::test_x[a-b]"])
SlugsAndNumbersTest.test_upsert_keeps_slugs_and_makes_them_unique
· Deep copies
|
2 ms |
|
apps/projects/models.py:230
self.bulk_create( # sorted, so uploads sharing tests lock their rows in the same order
TestManager.upsert
· Database
|
2 ms |
|
apps/projects/models.py:236
return {test.name: test for test in self.filter(project=project, name__in=names)}
TestManager.upsert
· Database
|
2 ms |
Fixtures
Exact setup time| _django_db_marker function | 0.05 ms |
| _live_server_helper function | 0.05 ms |
| _template_string_if_invalid_marker function | 0.05 ms |
| _django_set_urlconf function | 0.05 ms |
| _dj_autoclear_mailbox function | 0.04 ms |
| _django_clear_site_cache function | 0.03 ms |
| monkeypatch function | 0.03 ms |
Database
16 queries · 6 ms
Repeated queries are usually N+1 lookups: fetch them once with select_related / prefetch_related (or selectinload).
3×
SELECT "projects_test"."name" AS "name", "projects_test"."slug" AS "slug" FROM "projects_test" WHERE ("projects_test"."name" IN (…) AND "projects_test"."project_id" = %s)
3×
SELECT "projects_test"."slug" AS "slug" FROM "projects_test" WHERE ("projects_test"."project_id" = %s AND "projects_test"."slug" IN (…))
Biggest pieces of work
|
call test body
apps/projects/tests.py:1441
|
10 ms |
|
call _post_teardown
django/test/testcases.py:1240
|
2 ms |
| setup pytest internals | 0.86 ms |
Reliability
5 results · 0 CI failures · 0 local failuresThis test hasn't failed recently.
History
Latest 5 results, oldest first in the strip| When | Environment | Outcome | Duration | |
|---|---|---|---|---|
| 48 minutes ago | CI github-actions:test | passed | 14 ms | Profile |
| an hour ago | CI github-actions:test | passed | 13 ms | Profile |
| 7 hours ago | CI github-actions:test | passed | 17 ms | Profile |
| 8 hours ago | CI github-actions:test | passed | 8 ms | Profile |
| 8 hours ago | CI github-actions:test | passed | 14 ms | Profile |