flakytest.dev anze3db fedidevs
Tests / stats/tests.py

TestStats::test_store_daily_stats

First seen 2 years, 11 months ago in 1cd3a8d
CI github-actions:test 11 runs
Average
146 ms
median 132 ms
max 236 ms
Phases
Setup 5 ms Call 141 ms Teardown 0.74 ms
Categories
Database 142 ms App code 2 ms Other (Unsampled, pytest, Libraries) 2 ms

102 database queries per run

Needs 1 KB of memory (max 8 KB)

Duration per run

Where the time goes

Latest run in ci:github-actions:test, 7 hours ago · open run
Show pytest frames
setup2 ms1.7%
call131 ms98.1%
TestStats.test_store_daily_statsstats/tests.py:25 store_daily_stats()128 ms96.1%
store_daily_statsstats/models.py:20 ).count()63 ms47.6%
QuerySet.countdjango/db/models/query.py:67763 ms47.6%
Query.get_countdjango/db/models/sql/query.py:65762 ms46.6%
Query.get_aggregationdjango/db/models/sql/query.py:63957 ms42.6%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:162550 ms37.7%
CursorWrapper.executedjango/db/backends/utils.py:7950 ms37.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:9250 ms37.7%
CursorWrapper._executedjango/db/backends/utils.py:10549 ms36.7%
Cursor.executepsycopg/cursor.py:11349 ms36.7%
Connection.waitpsycopg/connection.py:49549 ms36.7%
BaseCursor._execute_genpsycopg/_cursor_base.py:20644 ms32.7%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:28640 ms29.7%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:7840 ms29.7%
BaseCursor._convert_querypsycopg/_cursor_base.py:4653 ms2.0%
PostgresClientQuery.convertpsycopg/_queries.py:2893 ms2.0%
PostgresClientQuery.dumppsycopg/_queries.py:2991 ms1.0%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:3181 ms1.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16124 ms3.0%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7934 ms3.0%
SQLCompiler.get_from_clausedjango/db/models/sql/compiler.py:11604 ms3.0%
SQLCompiler.compiledjango/db/models/sql/compiler.py:5794 ms3.0%
Join.as_sqldjango/db/models/sql/datastructures.py:884 ms3.0%
DatabaseOperations.prepare_join_on_clausedjango/db/backends/postgresql/operations.py:4024 ms3.0%
ForeignKey.db_typedjango/db/models/fields/related.py:13093 ms2.0%
BigAutoField.rel_db_typedjango/db/models/fields/__init__.py:29771 ms1.0%
Field.db_typedjango/db/models/fields/__init__.py:9271 ms1.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16231 ms1.0%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261 ms1.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16441 ms1.0%
CursorWrapper.__getattr__django/db/backends/utils.py:331 ms1.0%
Query.get_aggregationdjango/db/models/sql/query.py:4983 ms2.0%
Query.get_aggregationdjango/db/models/sql/query.py:6381 ms1.0%
Query.get_aggregationdjango/db/models/sql/query.py:4911 ms1.0%
Expression.__hash__django/db/models/expressions.py:5621 ms1.0%
cached_property.__get__django/utils/functional.py:471 ms1.0%
Expression.identitydjango/db/models/expressions.py:5521 ms1.0%
Query.get_countdjango/db/models/sql/query.py:6561 ms1.0%
store_daily_statsstats/models.py:12 f"{lang.code}_accounts": AccountLookup.objects.filter(language__icontains=lang.code + "\n").count()49 ms36.7%
QuerySet.countdjango/db/models/query.py:67746 ms34.7%
Query.get_countdjango/db/models/sql/query.py:65746 ms34.7%
Query.get_aggregationdjango/db/models/sql/query.py:63942 ms31.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:162540 ms29.7%
CursorWrapper.executedjango/db/backends/utils.py:7940 ms29.7%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:9240 ms29.7%
CursorWrapper._executedjango/db/backends/utils.py:10540 ms29.7%
Cursor.executepsycopg/cursor.py:11340 ms29.7%
Connection.waitpsycopg/connection.py:49540 ms29.7%
BaseCursor._execute_genpsycopg/_cursor_base.py:20613 ms9.9%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:28613 ms9.9%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:7813 ms9.9%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16123 ms2.0%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:9791 ms1.0%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:9821 ms1.0%
Query.get_aggregationdjango/db/models/sql/query.py:6443 ms2.0%
SQLCompiler.get_convertersdjango/db/models/sql/compiler.py:15271 ms1.0%
BaseExpression.get_db_convertersdjango/db/models/expressions.py:2071 ms1.0%
Query.get_aggregationdjango/db/models/sql/query.py:6341 ms1.0%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:871 ms1.0%
QuerySet.filterdjango/db/models/query.py:16761 ms1.0%
QuerySet._filter_or_excludedjango/db/models/query.py:16941 ms1.0%
QuerySet._filter_or_exclude_inplacedjango/db/models/query.py:17041 ms1.0%
Query.add_qdjango/db/models/sql/query.py:16841 ms1.0%
store_daily_statsstats/models.py:25 Daily.objects.update_or_create(date=today, defaults=account_defaults | post_defaults)8 ms5.9%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:878 ms5.9%
QuerySet.update_or_createdjango/db/models/query.py:10967 ms5.0%
QuerySet.get_or_createdjango/db/models/query.py:10543 ms2.0%
QuerySet.getdjango/db/models/query.py:7023 ms2.0%
QuerySet.__len__django/db/models/query.py:4213 ms2.0%
QuerySet._fetch_alldjango/db/models/query.py:22623 ms2.0%
ModelIterable.__iter__django/db/models/query.py:1033 ms2.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16121 ms1.0%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7681 ms1.0%
SQLCompiler.pre_sql_setupdjango/db/models/sql/compiler.py:891 ms1.0%
SQLCompiler.setup_querydjango/db/models/sql/compiler.py:781 ms1.0%
SQLCompiler.get_selectdjango/db/models/sql/compiler.py:3191 ms1.0%
SQLCompiler.compiledjango/db/models/sql/compiler.py:5791 ms1.0%
Col.as_sqldjango/db/models/expressions.py:13671 ms1.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.0%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.0%
CursorWrapper._executedjango/db/backends/utils.py:1051 ms1.0%
Cursor.executepsycopg/cursor.py:1131 ms1.0%
Connection.waitpsycopg/connection.py:4951 ms1.0%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.0%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.0%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.0%
QuerySet.get_or_createdjango/db/models/query.py:10613 ms2.0%
QuerySet.createdjango/db/models/query.py:7363 ms2.0%
Model.savedjango/db/models/base.py:9043 ms2.0%
Model.save_basedjango/db/models/base.py:9963 ms2.0%
Model._save_tabledjango/db/models/base.py:11993 ms2.0%
Model._do_insertdjango/db/models/base.py:12513 ms2.0%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:873 ms2.0%
QuerySet._insertdjango/db/models/query.py:21413 ms2.0%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19363 ms2.0%
CursorWrapper.executedjango/db/backends/utils.py:793 ms2.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:923 ms2.0%
QuerySet.get_or_createdjango/db/models/query.py:10591 ms1.0%
Atomic.__enter__django/db/transaction.py:2231 ms1.0%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261 ms1.0%
BaseDatabaseWrapper.savepointdjango/db/backends/base/base.py:4001 ms1.0%
BaseDatabaseWrapper._savepointdjango/db/backends/base/base.py:3671 ms1.0%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.0%
CursorWrapper._executedjango/db/backends/utils.py:1031 ms1.0%
Cursor.executepsycopg/cursor.py:1131 ms1.0%
Connection.waitpsycopg/connection.py:4951 ms1.0%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.0%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.0%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.0%
QuerySet.update_or_createdjango/db/models/query.py:10931 ms1.0%
Atomic.__enter__django/db/transaction.py:2231 ms1.0%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261 ms1.0%
BaseDatabaseWrapper.savepointdjango/db/backends/base/base.py:4001 ms1.0%
BaseDatabaseWrapper._savepointdjango/db/backends/base/base.py:3671 ms1.0%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.0%
CursorWrapper._executedjango/db/backends/utils.py:1031 ms1.0%
Cursor.executepsycopg/cursor.py:1131 ms1.0%
Connection.waitpsycopg/connection.py:4951 ms1.0%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.0%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.0%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.0%
store_daily_statsstats/models.py:18 f"{lang.code}_posts": Post.objects.filter(7 ms5.0%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:875 ms4.0%
QuerySet.filterdjango/db/models/query.py:16765 ms4.0%
QuerySet._filter_or_excludedjango/db/models/query.py:16945 ms4.0%
QuerySet._filter_or_exclude_inplacedjango/db/models/query.py:17045 ms4.0%
Query.add_qdjango/db/models/sql/query.py:16814 ms3.0%
Query._add_qdjango/db/models/sql/query.py:17134 ms3.0%
Query.build_filterdjango/db/models/sql/query.py:15773 ms2.0%
Query.setup_joinsdjango/db/models/sql/query.py:20021 ms1.0%
Query.build_filterdjango/db/models/sql/query.py:15511 ms1.0%
Query.solve_lookup_typedjango/db/models/sql/query.py:13581 ms1.0%
Query.names_to_pathdjango/db/models/sql/query.py:18221 ms1.0%
store_daily_statsstats/models.py:15 account_defaults["total_accounts"] = Account.objects.filter(accountlookup__isnull=False).count()1 ms1.0%
QuerySet.countdjango/db/models/query.py:6771 ms1.0%
Query.get_countdjango/db/models/sql/query.py:6571 ms1.0%
Query.get_aggregationdjango/db/models/sql/query.py:6391 ms1.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.0%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.0%
TestStats.test_store_daily_statsstats/tests.py:26 daily = Daily.objects.get(date=timezone.now().date())1 ms1.0%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:871 ms1.0%
QuerySet.getdjango/db/models/query.py:7021 ms1.0%
QuerySet.__len__django/db/models/query.py:4211 ms1.0%
QuerySet._fetch_alldjango/db/models/query.py:22621 ms1.0%
ModelIterable.__iter__django/db/models/query.py:1031 ms1.0%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.0%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.0%
CursorWrapper._executedjango/db/backends/utils.py:1051 ms1.0%
Cursor.executepsycopg/cursor.py:1131 ms1.0%
Connection.waitpsycopg/connection.py:4951 ms1.0%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.0%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.0%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.0%
TransactionTestCase._post_teardowndjango/test/testcases.py:1243 self._fixture_teardown()1 ms1.0%
TestCase._fixture_teardowndjango/test/testcases.py:14971 ms1.0%
TestCase._should_check_constraintsdjango/test/testcases.py:15061 ms1.0%
DatabaseWrapper.is_usabledjango/db/backends/postgresql/base.py:5041 ms1.0%
Cursor.executepsycopg/cursor.py:1131 ms1.0%
Connection.waitpsycopg/connection.py:4951 ms1.0%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.0%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.0%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.0%
Estimated from 101 samples; phase durations are exact. Frames from pytest and pluggy are hidden .

Hot lines in your code

stats/models.py:20
).count()
store_daily_stats · Database
63 ms
stats/models.py:12
f"{lang.code}_accounts": AccountLookup.objects.filter(language__icontains=lang.code + "\n").count()
store_daily_stats · Database
49 ms
stats/models.py:25
Daily.objects.update_or_create(date=today, defaults=account_defaults | post_defaults)
store_daily_stats · Database
8 ms
stats/models.py:18
f"{lang.code}_posts": Post.objects.filter(
store_daily_stats · Database
7 ms
stats/models.py:15
account_defaults["total_accounts"] = Account.objects.filter(accountlookup__isnull=False).count()
store_daily_stats · Database
1 ms
stats/tests.py:26
daily = Daily.objects.get(date=timezone.now().date())
TestStats.test_store_daily_stats · Database
1 ms

Fixtures

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

Database

102 queries · 79 ms

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

44×
SELECT COUNT(*) AS "__count" FROM "accounts_accountlookup" WHERE UPPER("accounts_accountlookup"."language"::text) LIKE UPPER(%s)
44×
SELECT COUNT(*) AS "__count" FROM "posts_post" INNER JOIN "accounts_account" ON ("posts_post"."account_id" = "accounts_account"."id") INNER JOIN "accounts_accountlookup" ON ("accounts_account"."id" = "accounts_accountlookup"."account_id") WHERE UPPER("accounts_accountlookup"."language"::text) LIKE …

Biggest pieces of work

call test body
stats/tests.py:25
129 ms
setup pytest internals 2 ms
call _post_teardown
django/test/testcases.py:1243
1 ms

Reliability

12 results · 0 CI failures · 0 local failures

This test hasn't failed recently.

History

Latest 12 results, oldest first in the strip
When Environment Outcome Duration Commit
7 hours ago CI github-actions:test passed 133 ms c28a326 main Profile
16 hours ago CI github-actions:test passed 103 ms 9b8826a main Profile
22 hours ago CI github-actions:test passed 117 ms 4f01055 main Profile
1 week, 5 days ago CI github-actions:test passed 196 ms 8ab642e main Profile
2 weeks, 2 days ago CI github-actions:test passed 97 ms 9b75244 main Profile
2 weeks, 2 days ago CI github-actions:test passed 113 ms 9603516 main Profile
2 weeks, 4 days ago CI github-actions:test passed 132 ms 615a272 main Profile
3 weeks ago CI github-actions:test passed 74 ms d923a46 main Profile
3 weeks ago CI github-actions:test passed 217 ms 82997f8 main Profile
3 weeks ago CI github-actions:test passed 236 ms 623aa3e main Profile
3 weeks ago CI github-actions:test passed 188 ms ab6465a main Profile
3 weeks ago CI github-actions:test passed 108 ms 0c23747 main Run