Skip to content

Commit

Permalink
Reduce thread count in stress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ocoanet committed Jan 20, 2024
1 parent 6b5fd96 commit dcc8602
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Disruptor.Tests/DisruptorStressTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void ShouldHandleLotsOfThreads_AsyncBatchEventHandler()
var ringBuffer = disruptor.RingBuffer;
disruptor.SetDefaultExceptionHandler(new FatalExceptionHandler<TestEvent>());

var publisherCount = Math.Max(1, Environment.ProcessorCount / 2);
var handlerCount = Math.Max(1, Environment.ProcessorCount / 2);
var publisherCount = Math.Clamp(Environment.ProcessorCount / 2, 1, 8);
var handlerCount = Math.Clamp(Environment.ProcessorCount / 2, 1, 8);

var end = new CountdownEvent(publisherCount);
var start = new CountdownEvent(publisherCount);
Expand Down
8 changes: 3 additions & 5 deletions src/Disruptor.Tests/WorkerStressTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ public void ShouldHandleLotsOfThreads()
var ringBuffer = disruptor.RingBuffer;
disruptor.SetDefaultExceptionHandler(new FatalExceptionHandler<TestEvent>());

var threads = Math.Max(1, Environment.ProcessorCount / 2);

const int iterations = 20_000_000;
var publisherCount = threads;
var handlerCount = threads;
var publisherCount = Math.Clamp(Environment.ProcessorCount / 2, 1, 8);
var handlerCount = Math.Clamp(Environment.ProcessorCount / 2, 1, 8);

var end = new CountdownEvent(publisherCount);
var start = new CountdownEvent(publisherCount);
Expand Down Expand Up @@ -154,4 +152,4 @@ private class TestEvent
// The string member was removed because it was not really useful for the test
// but the allocations made the test too slow.
}
}
}

0 comments on commit dcc8602

Please sign in to comment.