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

TestStats::test_store_daily_stats_with_accounts

First seen 3 years ago in 1cd3a8d
CI github-actions:test 13 runs
Average
154 ms
median 131 ms
max 322 ms
Phases
Setup 4 ms Call 147 ms Teardown 3 ms
Categories
Database 149 ms App code 1 ms Other (pytest, Unsampled, Libraries) 3 ms

104 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, 2 weeks ago · open run
Show pytest frames
call95 ms95.1%
TestStats.test_store_daily_stats_with_accountsstats/tests.py:60 store_daily_stats()91 ms90.5%
store_daily_statsstats/models.py:20 ).count()53 ms52.7%
QuerySet.countdjango/db/models/query.py:67753 ms52.7%
Query.get_countdjango/db/models/sql/query.py:65753 ms52.7%
Query.get_aggregationdjango/db/models/sql/query.py:63952 ms51.5%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:162547 ms47.0%
CursorWrapper.executedjango/db/backends/utils.py:7947 ms47.0%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:9247 ms47.0%
CursorWrapper._executedjango/db/backends/utils.py:10547 ms47.0%
Cursor.executepsycopg/cursor.py:11347 ms47.0%
Connection.waitpsycopg/connection.py:49546 ms45.8%
BaseCursor._execute_genpsycopg/_cursor_base.py:20632 ms32.1%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:28631 ms30.9%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:7831 ms30.9%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:3181 ms1.1%
BaseCursor._set_resultspsycopg/_cursor_base.py:5351 ms1.1%
BaseCursor._select_current_resultpsycopg/_cursor_base.py:5141 ms1.1%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16123 ms3.4%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:9791 ms1.1%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7901 ms1.1%
SQLCompiler.get_distinctdjango/db/models/sql/compiler.py:10441 ms1.1%
Query.get_metadjango/db/models/sql/query.py:3861 ms1.1%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:8251 ms1.1%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16231 ms1.1%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261 ms1.1%
Query.get_aggregationdjango/db/models/sql/query.py:4721 ms1.1%
Count.resolve_expressiondjango/db/models/aggregates.py:3121 ms1.1%
Aggregate.resolve_expressiondjango/db/models/aggregates.py:1251 ms1.1%
BaseExpression.resolve_expressiondjango/db/models/expressions.py:2971 ms1.1%
Func.copydjango/db/models/expressions.py:11371 ms1.1%
BaseExpression.copydjango/db/models/expressions.py:4441 ms1.1%
copy<stdlib>/copy.py:901 ms1.1%
store_daily_statsstats/models.py:12 f"{lang.code}_accounts": AccountLookup.objects.filter(language__icontains=lang.code + "\n").count()30 ms29.8%
QuerySet.countdjango/db/models/query.py:67728 ms27.5%
Query.get_countdjango/db/models/sql/query.py:65728 ms27.5%
Query.get_aggregationdjango/db/models/sql/query.py:63925 ms25.2%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:162524 ms24.1%
CursorWrapper.executedjango/db/backends/utils.py:7924 ms24.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:9224 ms24.1%
CursorWrapper._executedjango/db/backends/utils.py:10524 ms24.1%
Cursor.executepsycopg/cursor.py:11324 ms24.1%
Connection.waitpsycopg/connection.py:49524 ms24.1%
BaseCursor._execute_genpsycopg/_cursor_base.py:20617 ms17.2%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:28617 ms17.2%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:7817 ms17.2%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16121 ms1.1%
Query.get_aggregationdjango/db/models/sql/query.py:4911 ms1.1%
Expression.__hash__django/db/models/expressions.py:5621 ms1.1%
Query.get_aggregationdjango/db/models/sql/query.py:6441 ms1.1%
SQLCompiler.get_convertersdjango/db/models/sql/compiler.py:15291 ms1.1%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms2.3%
BaseManager.get_querysetdjango/db/models/manager.py:1551 ms1.1%
QuerySet.__init__django/db/models/query.py:3371 ms1.1%
__init____init__:-11 ms1.1%
Query.__init__django/db/models/sql/query.py:3241 ms1.1%
QuerySet.filterdjango/db/models/query.py:16761 ms1.1%
store_daily_statsstats/models.py:25 Daily.objects.update_or_create(date=today, defaults=account_defaults | post_defaults)3 ms3.4%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:873 ms3.4%
QuerySet.update_or_createdjango/db/models/query.py:10932 ms2.3%
Atomic.__enter__django/db/transaction.py:2231 ms1.1%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261 ms1.1%
BaseDatabaseWrapper.savepointdjango/db/backends/base/base.py:4001 ms1.1%
BaseDatabaseWrapper._savepointdjango/db/backends/base/base.py:3671 ms1.1%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.1%
CursorWrapper._executedjango/db/backends/utils.py:1031 ms1.1%
Cursor.executepsycopg/cursor.py:1131 ms1.1%
Connection.waitpsycopg/connection.py:4951 ms1.1%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.1%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.1%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.1%
Atomic.__exit__django/db/transaction.py:2591 ms1.1%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261 ms1.1%
BaseDatabaseWrapper.savepoint_commitdjango/db/backends/base/base.py:4311 ms1.1%
BaseDatabaseWrapper._savepoint_commitdjango/db/backends/base/base.py:3751 ms1.1%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.1%
CursorWrapper._executedjango/db/backends/utils.py:1031 ms1.1%
Cursor.executepsycopg/cursor.py:1131 ms1.1%
Connection.waitpsycopg/connection.py:4951 ms1.1%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.1%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.1%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.1%
QuerySet.update_or_createdjango/db/models/query.py:10961 ms1.1%
QuerySet.get_or_createdjango/db/models/query.py:10541 ms1.1%
QuerySet.getdjango/db/models/query.py:7021 ms1.1%
QuerySet.__len__django/db/models/query.py:4211 ms1.1%
QuerySet._fetch_alldjango/db/models/query.py:22621 ms1.1%
ModelIterable.__iter__django/db/models/query.py:1031 ms1.1%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.1%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.1%
CursorWrapper._executedjango/db/backends/utils.py:1051 ms1.1%
Cursor.executepsycopg/cursor.py:1131 ms1.1%
Connection.waitpsycopg/connection.py:4951 ms1.1%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.1%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.1%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.1%
store_daily_statsstats/models.py:15 account_defaults["total_accounts"] = Account.objects.filter(accountlookup__isnull=False).count()2 ms2.3%
QuerySet.countdjango/db/models/query.py:6772 ms2.3%
Query.get_countdjango/db/models/sql/query.py:6572 ms2.3%
Query.get_aggregationdjango/db/models/sql/query.py:4911 ms1.1%
Expression.__hash__django/db/models/expressions.py:5621 ms1.1%
cached_property.__get__django/utils/functional.py:471 ms1.1%
Expression.identitydjango/db/models/expressions.py:5521 ms1.1%
Expression._identitydjango/db/models/expressions.py:5381 ms1.1%
make_hashabledjango/utils/hashable.py:201 ms1.1%
Expression.__hash__django/db/models/expressions.py:5621 ms1.1%
cached_property.__get__django/utils/functional.py:471 ms1.1%
Expression.identitydjango/db/models/expressions.py:5441 ms1.1%
BoundArguments.apply_defaults<stdlib>/inspect.py:29261 ms1.1%
Query.get_aggregationdjango/db/models/sql/query.py:6391 ms1.1%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.1%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.1%
CursorWrapper._executedjango/db/backends/utils.py:1051 ms1.1%
Cursor.executepsycopg/cursor.py:1131 ms1.1%
Connection.waitpsycopg/connection.py:4951 ms1.1%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.1%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.1%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.1%
store_daily_statsstats/models.py:18 f"{lang.code}_posts": Post.objects.filter(2 ms2.3%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:872 ms2.3%
QuerySet.filterdjango/db/models/query.py:16762 ms2.3%
QuerySet._filter_or_excludedjango/db/models/query.py:16942 ms2.3%
QuerySet._filter_or_exclude_inplacedjango/db/models/query.py:17042 ms2.3%
Query.add_qdjango/db/models/sql/query.py:16812 ms2.3%
Query._add_qdjango/db/models/sql/query.py:17132 ms2.3%
Query.build_filterdjango/db/models/sql/query.py:16131 ms1.1%
Query.build_lookupdjango/db/models/sql/query.py:14401 ms1.1%
Query.build_filterdjango/db/models/sql/query.py:15511 ms1.1%
Query.solve_lookup_typedjango/db/models/sql/query.py:13581 ms1.1%
Query.names_to_pathdjango/db/models/sql/query.py:18891 ms1.1%
TransactionTestCase._pre_setupdjango/test/testcases.py:1167 cls._fixture_setup()1 ms1.1%
TestCase._fixture_setupdjango/test/testcases.py:14811 ms1.1%
TestCase._enter_atomicsdjango/test/testcases.py:13991 ms1.1%
Atomic.__enter__django/db/transaction.py:2231 ms1.1%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261 ms1.1%
BaseDatabaseWrapper.savepointdjango/db/backends/base/base.py:4001 ms1.1%
BaseDatabaseWrapper._savepointdjango/db/backends/base/base.py:3671 ms1.1%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.1%
CursorWrapper._executedjango/db/backends/utils.py:1031 ms1.1%
Cursor.executepsycopg/cursor.py:1131 ms1.1%
Connection.waitpsycopg/connection.py:4951 ms1.1%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.1%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.1%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.1%
TestStats.test_store_daily_stats_with_accountsstats/tests.py:32 account = Account.objects.create(1 ms1.1%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:871 ms1.1%
QuerySet.createdjango/db/models/query.py:7361 ms1.1%
Model.savedjango/db/models/base.py:9041 ms1.1%
Model.save_basedjango/db/models/base.py:9961 ms1.1%
Model._save_tabledjango/db/models/base.py:11991 ms1.1%
Model._do_insertdjango/db/models/base.py:12511 ms1.1%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:871 ms1.1%
QuerySet._insertdjango/db/models/query.py:21411 ms1.1%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19351 ms1.1%
SQLInsertCompiler.as_sqldjango/db/models/sql/compiler.py:18221 ms1.1%
SQLInsertCompiler.pre_save_valdjango/db/models/sql/compiler.py:17561 ms1.1%
TestStats.test_store_daily_stats_with_accountsstats/tests.py:61 daily = Daily.objects.get(date=timezone.now().date())1 ms1.1%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:871 ms1.1%
QuerySet.getdjango/db/models/query.py:7021 ms1.1%
QuerySet.__len__django/db/models/query.py:4211 ms1.1%
QuerySet._fetch_alldjango/db/models/query.py:22621 ms1.1%
ModelIterable.__iter__django/db/models/query.py:1031 ms1.1%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.1%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.1%
CursorWrapper._executedjango/db/backends/utils.py:1051 ms1.1%
Cursor.executepsycopg/cursor.py:1131 ms1.1%
Connection.waitpsycopg/connection.py:4951 ms1.1%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.1%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.1%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.1%
TransactionTestCase._post_teardowndjango/test/testcases.py:1243 self._fixture_teardown()1 ms1.1%
TestCase._fixture_teardowndjango/test/testcases.py:14981 ms1.1%
DatabaseWrapper.check_constraintsdjango/db/backends/postgresql/base.py:4951 ms1.1%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.1%
CursorWrapper._executedjango/db/backends/utils.py:1031 ms1.1%
Cursor.executepsycopg/cursor.py:1131 ms1.1%
Connection.waitpsycopg/connection.py:4951 ms1.1%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.1%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.1%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.1%
teardown4 ms4.1%
TestCase.tearDownClassdjango/test/testcases.py:1458 conn.close()4 ms4.1%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:264 ms4.1%
BaseDatabaseWrapper.closedjango/db/backends/base/base.py:3554 ms4.1%
DatabaseWrapper._closedjango/db/backends/postgresql/base.py:4084 ms4.1%
Connection.closepsycopg/connection.py:2014 ms4.1%
Estimated from 86 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
53 ms
stats/models.py:12
f"{lang.code}_accounts": AccountLookup.objects.filter(language__icontains=lang.code + "\n").count()
store_daily_stats · Database
30 ms
stats/models.py:25
Daily.objects.update_or_create(date=today, defaults=account_defaults | post_defaults)
store_daily_stats · Database
3 ms
stats/models.py:15
account_defaults["total_accounts"] = Account.objects.filter(accountlookup__isnull=False).count()
store_daily_stats · Database
2 ms
stats/models.py:18
f"{lang.code}_posts": Post.objects.filter(
store_daily_stats · Database
2 ms
stats/tests.py:32
account = Account.objects.create(
TestStats.test_store_daily_stats_with_accounts · Database
1 ms
stats/tests.py:61
daily = Daily.objects.get(date=timezone.now().date())
TestStats.test_store_daily_stats_with_accounts · Database
1 ms

Fixtures

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

Database

104 queries · 54 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:60
93 ms
teardown tearDownClass
django/test/testcases.py:1458
4 ms
call _pre_setup
django/test/testcases.py:1167
1 ms
call _post_teardown
django/test/testcases.py:1243
1 ms

Reliability

14 results · 0 CI failures · 0 local failures

This test hasn't failed recently.

History

Latest 14 results, oldest first in the strip
When Environment Outcome Duration Commit
2 weeks ago CI github-actions:test passed 100 ms 28600ed main Profile
2 weeks, 5 days ago CI github-actions:test passed 131 ms 600b717 main Profile
2 weeks, 6 days ago CI github-actions:test passed 137 ms c28a326 main Profile
3 weeks ago CI github-actions:test passed 79 ms 9b8826a main Profile
3 weeks ago CI github-actions:test passed 173 ms 4f01055 main Profile
1 month ago CI github-actions:test passed 140 ms 8ab642e main Profile
1 month ago CI github-actions:test passed 121 ms 9b75244 main Profile
1 month ago CI github-actions:test passed 112 ms 9603516 main Profile
1 month, 1 week ago CI github-actions:test passed 128 ms 615a272 main Profile
1 month, 1 week ago CI github-actions:test passed 83 ms d923a46 main Profile
1 month, 1 week ago CI github-actions:test passed 245 ms 82997f8 main Profile
1 month, 1 week ago CI github-actions:test passed 224 ms 623aa3e main Profile
1 month, 1 week ago CI github-actions:test passed 322 ms ab6465a main Profile
1 month, 1 week ago CI github-actions:test passed 113 ms 0c23747 main Run