Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions TUnit.Engine/TUnitInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void Initialize(ExecuteRequestContext context)
{
ConfigureGlobalExceptionHandlers(context);
SetUpExceptionListeners();
ConfigureThreadPool();
ParseParameters();

// Discover hooks using the mode-specific service
Expand Down Expand Up @@ -54,6 +55,18 @@ private void ParseParameters()
}
}

private void ConfigureThreadPool()
{
// Optimize ThreadPool for parallel test execution
// This eliminates the default ~500ms thread injection delay when running many tests in parallel
// Users can call ThreadPool.SetMinThreads() in their test setup to override if needed
var processorCount = Environment.ProcessorCount;
var minWorkerThreads = Math.Max(processorCount * 4, 32);
var minIocpThreads = Math.Max(processorCount * 4, 32);

ThreadPool.SetMinThreads(minWorkerThreads, minIocpThreads);
}

private static void ConfigureGlobalExceptionHandlers(ExecuteRequestContext context)
{
// Handle unhandled exceptions on any thread
Expand Down
Loading