Skip to content

Commit

Permalink
Pre-allocate list size
Browse files Browse the repository at this point in the history
Try to avoid test flakiness from concurrent adds on a `List<T>` by pre-allocating what is hopefully enough capacity to avoid a re-size.
  • Loading branch information
martincostello committed Nov 17, 2023
1 parent 21a0e54 commit efedace
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class IssuesTests
[Fact]
public void StrategiesPerEndpoint_1365()
{
var events = new List<MeteringEvent>();
var events = new List<MeteringEvent>(1024);
using var listener = TestUtilities.EnablePollyMetering(events);
var services = new ServiceCollection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class TelemetryListenerImplTests : IDisposable
{
private readonly FakeLogger _logger;
private readonly ILoggerFactory _loggerFactory;
private readonly List<MeteringEvent> _events = [];
private readonly List<MeteringEvent> _events = new(1024);
private Action<TelemetryEventArguments<object, object>>? _onEvent;

public TelemetryListenerImplTests() => _loggerFactory = TestUtilities.CreateLoggerFactory(out _logger);
Expand Down

0 comments on commit efedace

Please sign in to comment.