test-backend: Enable single-threaded profiling when thread count is unspecified.

If the number of threads is not specified
while profiling then use a single thread. This is
because profiling across multiple threads (earlier
default behaviour) may obscure the accurate
measurement of which functions are the most costly
due to thread blocking.

Signed-off-by: Akshat <akshat25iiit@gmail.com>
This commit is contained in:
Akshat 2023-07-01 00:52:54 +05:30 committed by Tim Abbott
parent af11ddb3cf
commit e7f4700d76
1 changed files with 6 additions and 1 deletions

View File

@ -395,7 +395,12 @@ def main() -> None:
# dynamic resolution of the test runner type with the django-stubs mypy plugin.
TestRunner = cast("Type[Runner]", get_runner(settings))
parallel = default_parallel if options.processes is None else options.processes
if options.processes:
parallel = options.processes
elif options.profile:
parallel = 1
else:
parallel = default_parallel
if parallel > 1:
print(f"-- Running tests in parallel mode with {parallel} processes.", flush=True)
else: