Tests / stats/tests.py
TestStats::test_store_daily_stats
First seen 2 years, 10 months ago in 1cd3a8d
CI
github-actions:test
4 runs
Average
179 ms
median 203 ms
max 236 ms
max 236 ms
Phases
Setup 8 ms
Call 169 ms
Teardown 1 ms
Categories
Database 172 ms
App code 3 ms
Other (Unsampled, pytest, Libraries) 4 ms
102 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, 8 hours ago ·
open run
call72 ms98.3%
CallInfo.from_call_pytest/runner.py:36172 ms98.3%
call_and_report.<locals>.<lambda>_pytest/runner.py:25072 ms98.3%
HookCaller.__call__pluggy/_hooks.py:51272 ms98.3%
PluginManager._hookexecpluggy/_manager.py:12072 ms98.3%
_multicallpluggy/_callers.py:12172 ms98.3%
pytest_runtest_call_pytest/runner.py:18472 ms98.3%
_django_setup_unittest.<locals>.non_debugging_runtestpytest_django/plugin.py:61472 ms98.3%
SimpleTestCase.__call__django/test/testcases.py:31472 ms98.3%
SimpleTestCase._setup_and_calldjango/test/testcases.py:36971 ms96.5%
TestCase.__call__<stdlib>/unittest/case.py:74771 ms96.5%
TestCase.run<stdlib>/unittest/case.py:69171 ms96.5%
TestCase._callTestMethod<stdlib>/unittest/case.py:63771 ms96.5%
TestStats.test_store_daily_statsstats/tests.py:25 store_daily_stats()68 ms92.9%
store_daily_statsstats/models.py:20 ).count()36 ms48.3%
QuerySet.countdjango/db/models/query.py:67736 ms48.3%
Query.get_countdjango/db/models/sql/query.py:65736 ms48.3%
Query.get_aggregationdjango/db/models/sql/query.py:63933 ms44.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:162530 ms41.1%
CursorWrapper.executedjango/db/backends/utils.py:7930 ms41.1%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:9230 ms41.1%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:10029 ms39.3%
CursorWrapper._executedjango/db/backends/utils.py:10529 ms39.3%
Cursor.executepsycopg/cursor.py:11329 ms39.3%
Connection.waitpsycopg/connection.py:49529 ms39.3%
BaseCursor._execute_genpsycopg/_cursor_base.py:20628 ms37.5%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:28628 ms37.5%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:7828 ms37.5%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1021 ms1.8%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16123 ms3.6%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7931 ms1.8%
SQLCompiler.get_from_clausedjango/db/models/sql/compiler.py:11601 ms1.8%
SQLCompiler.compiledjango/db/models/sql/compiler.py:5791 ms1.8%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7681 ms1.8%
SQLCompiler.pre_sql_setupdjango/db/models/sql/compiler.py:911 ms1.8%
Query.get_aggregationdjango/db/models/sql/query.py:6381 ms1.8%
Query.get_compilerdjango/db/models/sql/query.py:3741 ms1.8%
Query.get_aggregationdjango/db/models/sql/query.py:6341 ms1.8%
store_daily_statsstats/models.py:12 f"{lang.code}_accounts": AccountLookup.objects.filter(language__icontains=lang.code + "\n").count()21 ms28.6%
QuerySet.countdjango/db/models/query.py:67720 ms26.8%
Query.get_countdjango/db/models/sql/query.py:65720 ms26.8%
Query.get_aggregationdjango/db/models/sql/query.py:63914 ms19.7%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:162511 ms14.3%
CursorWrapper.executedjango/db/backends/utils.py:7911 ms14.3%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:9211 ms14.3%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:10011 ms14.3%
CursorWrapper._executedjango/db/backends/utils.py:10511 ms14.3%
Cursor.executepsycopg/cursor.py:11311 ms14.3%
Connection.waitpsycopg/connection.py:49511 ms14.3%
BaseCursor._execute_genpsycopg/_cursor_base.py:20611 ms14.3%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2869 ms12.5%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:789 ms12.5%
BaseCursor._convert_querypsycopg/_cursor_base.py:4651 ms1.8%
PostgresClientQuery.convertpsycopg/_queries.py:2891 ms1.8%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16123 ms3.6%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7681 ms1.8%
SQLCompiler.pre_sql_setupdjango/db/models/sql/compiler.py:891 ms1.8%
SQLCompiler.setup_querydjango/db/models/sql/compiler.py:781 ms1.8%
SQLCompiler.get_selectdjango/db/models/sql/compiler.py:3191 ms1.8%
SQLCompiler.compiledjango/db/models/sql/compiler.py:5791 ms1.8%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7961 ms1.8%
SQLCompiler.compiledjango/db/models/sql/compiler.py:5791 ms1.8%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16231 ms1.8%
async_unsafe.<locals>.decorator.<locals>.innerdjango/utils/asyncio.py:261 ms1.8%
BaseDatabaseWrapper.cursordjango/db/backends/base/base.py:3201 ms1.8%
Query.get_aggregationdjango/db/models/sql/query.py:4723 ms3.6%
Count.resolve_expressiondjango/db/models/aggregates.py:3121 ms1.8%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.8%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.8%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.8%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1001 ms1.8%
CursorWrapper._executedjango/db/backends/utils.py:1051 ms1.8%
Cursor.executepsycopg/cursor.py:1131 ms1.8%
Connection.waitpsycopg/connection.py:4951 ms1.8%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.8%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.8%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.8%
Query.get_aggregationdjango/db/models/sql/query.py:6381 ms1.8%
Query.get_aggregationdjango/db/models/sql/query.py:4981 ms1.8%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:871 ms1.8%
QuerySet.filterdjango/db/models/query.py:16761 ms1.8%
QuerySet._filter_or_excludedjango/db/models/query.py:16941 ms1.8%
QuerySet._filter_or_exclude_inplacedjango/db/models/query.py:17041 ms1.8%
Query.add_qdjango/db/models/sql/query.py:16811 ms1.8%
store_daily_statsstats/models.py:25 Daily.objects.update_or_create(date=today, defaults=account_defaults | post_defaults)5 ms7.1%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:875 ms7.1%
QuerySet.update_or_createdjango/db/models/query.py:10965 ms7.1%
QuerySet.get_or_createdjango/db/models/query.py:10613 ms3.6%
QuerySet.createdjango/db/models/query.py:7363 ms3.6%
Model.savedjango/db/models/base.py:9043 ms3.6%
Model.save_basedjango/db/models/base.py:9963 ms3.6%
Model._save_tabledjango/db/models/base.py:11993 ms3.6%
Model._do_insertdjango/db/models/base.py:12513 ms3.6%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:873 ms3.6%
QuerySet._insertdjango/db/models/query.py:21413 ms3.6%
SQLInsertCompiler.execute_sqldjango/db/models/sql/compiler.py:19363 ms3.6%
CursorWrapper.executedjango/db/backends/utils.py:793 ms3.6%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:923 ms3.6%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1003 ms3.6%
CursorWrapper._executedjango/db/backends/utils.py:1053 ms3.6%
Cursor.executepsycopg/cursor.py:1133 ms3.6%
Connection.waitpsycopg/connection.py:4953 ms3.6%
BaseCursor._execute_genpsycopg/_cursor_base.py:2063 ms3.6%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2863 ms3.6%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:783 ms3.6%
QuerySet.get_or_createdjango/db/models/query.py:10543 ms3.6%
QuerySet.getdjango/db/models/query.py:7023 ms3.6%
QuerySet.__len__django/db/models/query.py:4213 ms3.6%
QuerySet._fetch_alldjango/db/models/query.py:22623 ms3.6%
ModelIterable.__iter__django/db/models/query.py:1033 ms3.6%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16121 ms1.8%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7681 ms1.8%
SQLCompiler.pre_sql_setupdjango/db/models/sql/compiler.py:891 ms1.8%
SQLCompiler.setup_querydjango/db/models/sql/compiler.py:781 ms1.8%
SQLCompiler.get_selectdjango/db/models/sql/compiler.py:3191 ms1.8%
SQLCompiler.compiledjango/db/models/sql/compiler.py:5751 ms1.8%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.8%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.8%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.8%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1021 ms1.8%
QueryStats.addflakytest/profiling/dbtrack.py:381 ms1.8%
normalize_sqlflakytest/profiling/dbtrack.py:231 ms1.8%
store_daily_statsstats/models.py:18 f"{lang.code}_posts": Post.objects.filter(4 ms5.4%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:873 ms3.6%
QuerySet.filterdjango/db/models/query.py:16763 ms3.6%
QuerySet._filter_or_excludedjango/db/models/query.py:16891 ms1.8%
QuerySet._filter_or_excludedjango/db/models/query.py:16941 ms1.8%
QuerySet._filter_or_exclude_inplacedjango/db/models/query.py:17041 ms1.8%
Query.add_qdjango/db/models/sql/query.py:16811 ms1.8%
Query._add_qdjango/db/models/sql/query.py:17131 ms1.8%
Query.build_filterdjango/db/models/sql/query.py:16111 ms1.8%
Query._get_coldjango/db/models/sql/query.py:4561 ms1.8%
store_daily_statsstats/models.py:23 post_defaults["total_posts"] = Post.objects.filter().count()3 ms3.6%
QuerySet.countdjango/db/models/query.py:6773 ms3.6%
Query.get_countdjango/db/models/sql/query.py:6573 ms3.6%
Query.get_aggregationdjango/db/models/sql/query.py:6393 ms3.6%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16253 ms3.6%
CursorWrapper.executedjango/db/backends/utils.py:793 ms3.6%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:923 ms3.6%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1003 ms3.6%
CursorWrapper._executedjango/db/backends/utils.py:1053 ms3.6%
Cursor.executepsycopg/cursor.py:1133 ms3.6%
Connection.waitpsycopg/connection.py:4953 ms3.6%
TestStats.test_store_daily_statsstats/tests.py:26 daily = Daily.objects.get(date=timezone.now().date())3 ms3.6%
BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_methoddjango/db/models/manager.py:873 ms3.6%
QuerySet.getdjango/db/models/query.py:7023 ms3.6%
QuerySet.__len__django/db/models/query.py:4213 ms3.6%
QuerySet._fetch_alldjango/db/models/query.py:22623 ms3.6%
ModelIterable.__iter__django/db/models/query.py:1033 ms3.6%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16121 ms1.8%
SQLCompiler.as_sqldjango/db/models/sql/compiler.py:7681 ms1.8%
SQLCompiler.pre_sql_setupdjango/db/models/sql/compiler.py:891 ms1.8%
SQLCompiler.setup_querydjango/db/models/sql/compiler.py:781 ms1.8%
SQLCompiler.get_selectdjango/db/models/sql/compiler.py:2651 ms1.8%
SQLCompiler.get_default_columnsdjango/db/models/sql/compiler.py:10301 ms1.8%
SQLCompiler.execute_sqldjango/db/models/sql/compiler.py:16251 ms1.8%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.8%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.8%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1001 ms1.8%
CursorWrapper._executedjango/db/backends/utils.py:1051 ms1.8%
Cursor.executepsycopg/cursor.py:1131 ms1.8%
Connection.waitpsycopg/connection.py:4951 ms1.8%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.8%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.8%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.8%
SimpleTestCase._setup_and_calldjango/test/testcases.py:3721 ms1.8%
TransactionTestCase._post_teardowndjango/test/testcases.py:1243 self._fixture_teardown()1 ms1.8%
TestCase._fixture_teardowndjango/test/testcases.py:14981 ms1.8%
DatabaseWrapper.check_constraintsdjango/db/backends/postgresql/base.py:4961 ms1.8%
CursorWrapper.executedjango/db/backends/utils.py:791 ms1.8%
CursorWrapper._execute_with_wrappersdjango/db/backends/utils.py:921 ms1.8%
QueryTracker._django_wrapperflakytest/profiling/dbtrack.py:1001 ms1.8%
CursorWrapper._executedjango/db/backends/utils.py:1031 ms1.8%
Cursor.executepsycopg/cursor.py:1131 ms1.8%
Connection.waitpsycopg/connection.py:4951 ms1.8%
BaseCursor._execute_genpsycopg/_cursor_base.py:2061 ms1.8%
BaseCursor._maybe_prepare_genpsycopg/_cursor_base.py:2861 ms1.8%
ClientCursorMixin._execute_sendpsycopg/client_cursor.py:781 ms1.8%
teardown0.58 ms0.8%
CallInfo.from_call_pytest/runner.py:3610.58 ms0.8%
call_and_report.<locals>.<lambda>_pytest/runner.py:2500.58 ms0.8%
HookCaller.__call__pluggy/_hooks.py:5120.58 ms0.8%
PluginManager._hookexecpluggy/_manager.py:1200.58 ms0.8%
_multicallpluggy/_callers.py:1160.58 ms0.8%
LoggingPlugin.pytest_runtest_teardown_pytest/logging.py:8720.58 ms0.8%
_GeneratorContextManager.__enter__<stdlib>/contextlib.py:2030.58 ms0.8%
LoggingPlugin._runtest_for_pytest/logging.py:8310.58 ms0.8%
catching_logs.__enter___pytest/logging.py:3590.58 ms0.8%
Estimated from 56 samples; phase durations are exact. Frames from pytest and pluggy are
shown
.
Hot lines in your code
|
stats/models.py:20
).count()
store_daily_stats
· Database
|
36 ms |
|
stats/models.py:12
f"{lang.code}_accounts": AccountLookup.objects.filter(language__icontains=lang.code + "\n").count()
store_daily_stats
· Database
|
21 ms |
|
stats/models.py:25
Daily.objects.update_or_create(date=today, defaults=account_defaults | post_defaults)
store_daily_stats
· Database
|
5 ms |
|
stats/models.py:18
f"{lang.code}_posts": Post.objects.filter(
store_daily_stats
· Database
|
4 ms |
|
stats/models.py:23
post_defaults["total_posts"] = Post.objects.filter().count()
store_daily_stats
· Database
|
3 ms |
|
stats/tests.py:26
daily = Daily.objects.get(date=timezone.now().date())
TestStats.test_store_daily_stats
· Database
|
3 ms |
Fixtures
Exact setup time| _dj_autoclear_mailbox function | 0.05 ms |
| _template_string_if_invalid_marker function | 0.03 ms |
| _django_db_marker function | 0.03 ms |
| _django_isolate_apps function | 0.03 ms |
| _live_server_helper function | 0.03 ms |
| _django_set_urlconf function | 0.02 ms |
| _django_clear_site_cache function | 0.02 ms |
| monkeypatch function | 0.01 ms |
Database
102 queries · 38 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
|
71 ms |
|
call _post_teardown
django/test/testcases.py:1243
|
1 ms |
| teardown pytest internals | 0.58 ms |
Reliability
5 results · 0 CI failures · 0 local failuresThis test hasn't failed recently.
History
Latest 50 results, oldest first in the strip| When | Environment | Outcome | Duration | |
|---|---|---|---|---|
| 8 hours ago | CI github-actions:test | passed | 74 ms | Profile |
| 8 hours ago | CI github-actions:test | passed | 217 ms | Profile |
| 8 hours ago | CI github-actions:test | passed | 236 ms | Profile |
| 13 hours ago | CI github-actions:test | passed | 188 ms | Profile |
| 14 hours ago | CI github-actions:test | passed | 108 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 66 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 91 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 83 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 98 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 87 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 89 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 89 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 92 ms | Run |
| 3 months, 3 weeks ago | CI github-actions | passed | 94 ms | Run |
| 3 months, 4 weeks ago | CI github-actions | passed | 92 ms | Run |
| 3 months, 4 weeks ago | CI github-actions | passed | 91 ms | Run |
| 3 months, 4 weeks ago | CI github-actions | passed | 93 ms | Run |
| 3 months, 4 weeks ago | CI github-actions | passed | 89 ms | Run |
| 3 months, 4 weeks ago | CI github-actions | passed | 92 ms | Run |
| 3 months, 4 weeks ago | CI github-actions | passed | 89 ms | Run |