From 8145e27f1d9453054e90d53b088860fc5c054d6b Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 24 Feb 2024 08:43:46 +0000 Subject: [PATCH] Added system check benchmark (#80) --- .../queryset_filter_chain/benchmark.py | 10 +++++++--- benchmarks/system_check_benchmarks/__init__.py | 0 .../system_check_benchmarks/run_checks/__init__.py | 0 .../system_check_benchmarks/run_checks/benchmark.py | 11 +++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 benchmarks/system_check_benchmarks/__init__.py create mode 100644 benchmarks/system_check_benchmarks/run_checks/__init__.py create mode 100644 benchmarks/system_check_benchmarks/run_checks/benchmark.py diff --git a/benchmarks/query_benchmarks/queryset_filter_chain/benchmark.py b/benchmarks/query_benchmarks/queryset_filter_chain/benchmark.py index 9f24df0f6c..61fedf4594 100644 --- a/benchmarks/query_benchmarks/queryset_filter_chain/benchmark.py +++ b/benchmarks/query_benchmarks/queryset_filter_chain/benchmark.py @@ -12,11 +12,15 @@ def time_filter_chain(self): Book.objects.filter(title="Talent").filter( description__icontains="top performers" ).filter(author_name__startswith="Geoff").filter( - date_created__lt=datetime.datetime(year=2010, month=1, day=1) + date_created__lt=datetime.datetime( + year=2010, month=1, day=1, tzinfo=datetime.timezone.utc + ) ).filter( - date_created__gte=datetime.date(year=2007, month=1, day=1) + date_created__gte=datetime.datetime( + year=2007, month=1, day=1, tzinfo=datetime.timezone.utc + ) ).filter( - date_published=datetime.datetime.now() + date_published=datetime.datetime.now(tz=datetime.timezone.utc) ).filter( enabled=True ) diff --git a/benchmarks/system_check_benchmarks/__init__.py b/benchmarks/system_check_benchmarks/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/benchmarks/system_check_benchmarks/run_checks/__init__.py b/benchmarks/system_check_benchmarks/run_checks/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/benchmarks/system_check_benchmarks/run_checks/benchmark.py b/benchmarks/system_check_benchmarks/run_checks/benchmark.py new file mode 100644 index 0000000000..66f5274bf0 --- /dev/null +++ b/benchmarks/system_check_benchmarks/run_checks/benchmark.py @@ -0,0 +1,11 @@ +from django.core.checks import run_checks + +from ...utils import bench_setup + + +class SystemChecks: + def setup(self): + bench_setup(migrate=True) + + def time_checks(self): + run_checks(include_deployment_checks=True, databases=("default",))