flakytest.dev anze3db flakytest
Tests / apps/projects/tests.py

AnalyticsTest::test_slow_tests_per_environment

First seen 9 hours ago in 78a4357
CI github-actions:test 5 runs
Average
28 ms
median 30 ms
max 33 ms
Phases
Setup 0.84 ms Call 27 ms Teardown 0.18 ms
Categories
Database 24 ms App code 4 ms Other (Unsampled, pytest) 1 ms

24 database queries per run

Needs 1 KB of memory (max 4 KB)

Duration per run

Where the time goes

Latest run in ci:github-actions:test, 2 hours ago · open run
Hide pytest frames
call29 ms96.7%
CallInfo.from_call_pytest/runner.py:35329 ms96.7%
call_and_report.<locals>.<lambda>_pytest/runner.py:24529 ms96.7%
HookCaller.__call__pluggy/_hooks.py:51229 ms96.7%
PluginManager._hookexecpluggy/_manager.py:12029 ms96.7%
_multicallpluggy/_callers.py:12129 ms96.7%
pytest_runtest_call_pytest/runner.py:17929 ms96.7%
_django_setup_unittest.<locals>.non_debugging_runtestpytest_django/plugin.py:57329 ms96.7%
SimpleTestCase.__call__django/test/testcases.py:31329 ms96.7%
SimpleTestCase._setup_and_calldjango/test/testcases.py:36825 ms83.8%
TestCase.__call__<stdlib>/unittest/case.py:74725 ms83.8%
TestCase.run<stdlib>/unittest/case.py:69125 ms83.8%
TestCase._callTestMethod<stdlib>/unittest/case.py:63725 ms83.8%
AnalyticsTest.test_slow_tests_per_environmentapps/projects/tests.py:748 ci_rows = slow_tests(resolve_scope(self.project, "ci"))11 ms38.7%
slow_testsapps/projects/analytics.py:465 suite_time = scope.profiles().aggregate(avg=Avg("test_time"))["avg"] or 04 ms12.9%
QuerySet.aggregatedjango/db/models/query.py:5942 ms6.4%
Query.get_aggregationdjango/db/models/sql/query.py:6332 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
resolve_scopeapps/projects/analytics.py:198 selected = Environment.objects.filter(project=project, name=env).first()2 ms6.4%
QuerySet.firstdjango/db/models/query.py:11452 ms6.4%
QuerySet.__iter__django/db/models/query.py:3902 ms6.4%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms6.4%
ModelIterable.__iter__django/db/models/query.py:952 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
resolve_scopeapps/projects/analytics.py:206 environments=list(Environment.objects.filter(project=project, kind=env)),2 ms6.4%
QuerySet.__iter__django/db/models/query.py:3902 ms6.4%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms6.4%
ModelIterable.__iter__django/db/models/query.py:952 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
slow_testsapps/projects/analytics.py:442 rows = list(2 ms6.4%
QuerySet.__iter__django/db/models/query.py:3902 ms6.4%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms6.4%
ValuesIterable.__iter__django/db/models/query.py:2222 ms6.4%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
slow_testsapps/projects/analytics.py:453 TestSnapshot.objects.filter(scope.environment_q(), test_id__in=ids)2 ms6.4%
QuerySet.__iter__django/db/models/query.py:3902 ms6.4%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms6.4%
ModelIterable.__iter__django/db/models/query.py:952 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16112 ms6.4%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7672 ms6.4%
SQLCompiler.pre_sql_setupdjango/db/models/sql/compiler.py:862 ms6.4%
SQLCompiler.setup_querydjango/db/models/sql/compiler.py:752 ms6.4%
SQLCompiler.get_selectdjango/db/models/sql/compiler.py:3172 ms6.4%
SQLCompiler.compiledjango/db/models/sql/compiler.py:5782 ms6.4%
AnalyticsTest.test_slow_tests_per_environmentapps/projects/tests.py:7518 ms25.8%
resolve_scopeapps/projects/analytics.py:198 selected = Environment.objects.filter(project=project, name=env).first()2 ms6.4%
QuerySet.firstdjango/db/models/query.py:11452 ms6.4%
QuerySet.__iter__django/db/models/query.py:3902 ms6.4%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms6.4%
ModelIterable.__iter__django/db/models/query.py:952 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
slow_testsapps/projects/analytics.py:442 rows = list(2 ms6.4%
QuerySet.__iter__django/db/models/query.py:3902 ms6.4%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms6.4%
ValuesIterable.__iter__django/db/models/query.py:2222 ms6.4%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
slow_testsapps/projects/analytics.py:461 for perf in TestPerf.objects.filter(2 ms6.4%
slow_testsapps/projects/analytics.py:4912 ms6.4%
whyapps/projects/analytics.py:4002 ms6.4%
category_barapps/projects/analytics.py:112 "share": seconds / total,2 ms6.4%
AnalyticsTest.test_slow_tests_per_environmentapps/projects/tests.py:7536 ms19.3%
slow_testsapps/projects/analytics.py:442 rows = list(2 ms6.4%
QuerySet.__iter__django/db/models/query.py:3902 ms6.4%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms6.4%
ValuesIterable.__iter__django/db/models/query.py:2222 ms6.4%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
slow_testsapps/projects/analytics.py:4502 ms6.4%
categories_by_testapps/projects/analytics.py:424 for test_id, run_count, categories in rows.filter(test_id__in=test_ids).values_list(2 ms6.4%
QuerySet.__iter__django/db/models/query.py:3902 ms6.4%
QuerySet._fetch_alldjango/db/models/query.py:20002 ms6.4%
ValuesListIterable.__iter__django/db/models/query.py:2382 ms6.4%
SQLCompiler.results_iterdjango/db/models/sql/compiler.py:15732 ms6.4%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16242 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1052 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
BaseCursor._execute_genpsycopg/_cursor_base.py:2062 ms6.4%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2862 ms6.4%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:782 ms6.4%
slow_testsapps/projects/analytics.py:461 for perf in TestPerf.objects.filter(2 ms6.4%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms6.4%
QuerySet.filterdjango/db/models/query.py:15422 ms6.4%
QuerySet._filter_or_excludedjango/db/models/query.py:15602 ms6.4%
QuerySet._filter_or_exclude_inplacedjango/db/models/query.py:15702 ms6.4%
Query.add_qdjango/db/models/sql/query.py:16712 ms6.4%
Query._add_qdjango/db/models/sql/query.py:17032 ms6.4%
Query.build_filterdjango/db/models/sql/query.py:15772 ms6.4%
SimpleTestCase._setup_and_calldjango/test/testcases.py:3592 ms6.4%
TransactionTestCase._pre_setupdjango/test/testcases.py:1164 cls._fixture_setup()2 ms6.4%
TestCase._fixture_setupdjango/test/testcases.py:14782 ms6.4%
TestCase._enter_atomicsdjango/test/testcases.py:13962 ms6.4%
Atomic.__enter__django/db/transaction.py:2112 ms6.4%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:262 ms6.4%
BaseDatabaseWrapper.savepointdjango/db/backends/base/base.py:4002 ms6.4%
BaseDatabaseWrapper._savepointdjango/db/backends/base/base.py:3672 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1032 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
SimpleTestCase._setup_and_calldjango/test/testcases.py:3712 ms6.4%
TransactionTestCase._post_teardowndjango/test/testcases.py:1240 self._fixture_teardown()2 ms6.4%
TestCase._fixture_teardowndjango/test/testcases.py:14952 ms6.4%
DatabaseWrapper.check_constraintsdjango/db/backends/postgresql/base.py:4832 ms6.4%
CursorWrapper.executedjango/db/backends/utils.py:792 ms6.4%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:922 ms6.4%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1002 ms6.4%
CursorWrapper._executedjango/db/backends/utils.py:1032 ms6.4%
Cursor.executepsycopg/cursor.py:1132 ms6.4%
Connection.waitpsycopg/connection.py:4952 ms6.4%
Estimated from 15 samples; phase durations are exact. Frames from pytest and pluggy are shown .

Hot lines in your code

apps/projects/analytics.py:442
rows = list(
slow_tests · Database
6 ms
apps/projects/analytics.py:198
selected = Environment.objects.filter(project=project, name=env).first()
resolve_scope · Database
4 ms
apps/projects/analytics.py:465
suite_time = scope.profiles().aggregate(avg=Avg("test_time"))["avg"] or 0
slow_tests · App code
4 ms
apps/projects/analytics.py:461
for perf in TestPerf.objects.filter(
slow_tests · App code
4 ms
apps/projects/analytics.py:206
environments=list(Environment.objects.filter(project=project, kind=env)),
resolve_scope · Database
2 ms
apps/projects/analytics.py:453
TestSnapshot.objects.filter(scope.environment_q(), test_id__in=ids)
slow_tests · Database
2 ms
apps/projects/analytics.py:112
"share": seconds / total,
category_bar · App code
2 ms
apps/projects/analytics.py:424
for test_id, run_count, categories in rows.filter(test_id__in=test_ids).values_list(
categories_by_test · Database
2 ms

Fixtures

Exact setup time
_django_db_marker function 0.06 ms
monkeypatch function 0.05 ms
_template_string_if_invalid_marker function 0.05 ms
_live_server_helper function 0.05 ms
_django_set_urlconf function 0.04 ms
_dj_autoclear_mailbox function 0.04 ms
_django_clear_site_cache function 0.03 ms

Database

24 queries · 11 ms

Repeated queries are usually N+1 lookups: fetch them once with select_related / prefetch_related (or selectinload).

4×
SELECT "projects_environment"."id", "projects_environment"."project_id", "projects_environment"."name", "projects_environment"."kind", "projects_environment"."provider", "projects_environment"."details", "projects_environment"."date_first_seen", "projects_environment"."date_last_seen" FROM "project…
3×
SELECT "projects_testdailystats"."test_id" AS "test_id", "projects_test"."name" AS "test__name", "projects_test"."slug" AS "test__slug", SUM("projects_testdailystats"."runs") AS "runs_sum", SUM("projects_testdailystats"."duration_sum") AS "duration_total", MAX("projects_testdailystats"."duration_ma…
3×
SELECT "projects_testsnapshot"."id", "projects_testsnapshot"."project_id", "projects_testsnapshot"."test_id", "projects_testsnapshot"."environment_id", "projects_testsnapshot"."profile_id", "projects_testsnapshot"."date", "projects_testsnapshot"."segments", "projects_environment"."id", "projects_en…
3×
SELECT "projects_testperf"."id", "projects_testperf"."test_id", "projects_testperf"."profile_id", "projects_testperf"."db_duplicates" FROM "projects_testperf" WHERE ("projects_testperf"."profile_id" IN (…) AND "projects_testperf"."test_id" IN (…))

Biggest pieces of work

call test body
apps/projects/tests.py:748
25 ms
call _pre_setup
django/test/testcases.py:1164
2 ms
call _post_teardown
django/test/testcases.py:1240
2 ms

Reliability

5 results · 0 CI failures · 0 local failures

This test hasn't failed recently.

History

Latest 5 results, oldest first in the strip
When Environment Outcome Duration Commit
2 hours ago CI github-actions:test passed 30 ms 9caa567 main Profile
2 hours ago CI github-actions:test passed 29 ms ec75501 main Profile
9 hours ago CI github-actions:test passed 33 ms d2c12e5 main Profile
9 hours ago CI github-actions:test passed 19 ms 0b902f6 main Profile
9 hours ago CI github-actions:test passed 30 ms 78a4357 main Profile