Make ParallelMessageProcessingTest stable by loose the assertion (#1786)

This commit is contained in:
Hai Cao
2022-12-13 15:01:01 -08:00
committed by GitHub
parent 548229d547
commit 1559b7c387

View File

@@ -93,11 +93,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Messaging
int numOfRequests = 10;
int msForEachRequest = 1000;
// Without parallel processing, this should take around numOfRequests * msForEachRequest ms to finish.
// With parallel process, this should take around 1 * msForEachRequest ms to finish.
// The diff should be around (numOfRequests - 1) * msForEachRequest ms.
// In order to make this test stable, we loose the assertion by checking the diff against
// (numOfRequests / 2) * msForEachRequest ms, which should for sure pass.
Assert.IsTrue(GetTimeToHandleRequests(false, numOfRequests, msForEachRequest) - GetTimeToHandleRequests(true, numOfRequests, msForEachRequest) > msForEachRequest * (numOfRequests / 2));
// With parallel process, this should take around 1 * msForEachRequest ms to finish in theory (with perfect parallelism).
// The diff should in theory be around (numOfRequests - 1) * msForEachRequest ms.
// In order to make this test stable on machines with poor hardware / few logical cores,
// we loose the assertion by only checking parallel process being faster than sequential processing.
Assert.IsTrue(GetTimeToHandleRequests(false, numOfRequests, msForEachRequest) > GetTimeToHandleRequests(true, numOfRequests, msForEachRequest));
}