-
Notifications
You must be signed in to change notification settings - Fork 346
perf: fix dictionary double-lookups, Collection.Contains, and LINQ allocations #15533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
351e1dc
597b533
1da146e
b4af0f9
038b6c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,16 +53,12 @@ public IDictionary<string, string> GetDataCollectionDataSetForTestCase(Guid test | |
|
|
||
| private void AddKeyValuePairToDictionary(Guid testCaseId, string key, string value) | ||
| { | ||
| if (!_testCaseDataCollectionDataMap.ContainsKey(testCaseId)) | ||
| if (!_testCaseDataCollectionDataMap.TryGetValue(testCaseId, out var testCaseCollectionData)) | ||
| { | ||
| var testCaseCollectionData = new TestCaseDataCollectionData(); | ||
| testCaseCollectionData.AddOrUpdateData(key, value); | ||
| testCaseCollectionData = new TestCaseDataCollectionData(); | ||
| _testCaseDataCollectionDataMap[testCaseId] = testCaseCollectionData; | ||
| } | ||
| else | ||
| { | ||
| _testCaseDataCollectionDataMap[testCaseId].AddOrUpdateData(key, value); | ||
| } | ||
| testCaseCollectionData.AddOrUpdateData(key, value); | ||
| } | ||
|
|
||
| private class TestCaseDataCollectionData | ||
|
|
@@ -76,15 +72,11 @@ public TestCaseDataCollectionData() | |
|
|
||
| internal void AddOrUpdateData(string key, string value) | ||
| { | ||
| if (!CollectionData.ContainsKey(key)) | ||
| { | ||
| CollectionData[key] = value; | ||
| } | ||
| else | ||
| if (CollectionData.ContainsKey(key)) | ||
| { | ||
| EqtTrace.Warning("The data for in-proc data collector with key {0} has already been set. Will be reset with new value", key); | ||
| CollectionData[key] = value; | ||
| } | ||
| CollectionData[key] = value; | ||
|
Comment on lines
+75
to
+79
|
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |||||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||||||
|
|
||||||
| using System.Collections.Generic; | ||||||
| using System.Collections.ObjectModel; | ||||||
| using System.Linq; | ||||||
| using System.Threading; | ||||||
|
|
||||||
| using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; | ||||||
|
|
@@ -67,7 +69,7 @@ public override void HandleTestRunComplete( | |||||
| _runDataAggregator.IsAborted, | ||||||
| _runDataAggregator.GetAggregatedException(), | ||||||
| _runDataAggregator.RunContextAttachments, | ||||||
| _runDataAggregator.InvokedDataCollectors, | ||||||
| new Collection<InvokedDataCollector>(_runDataAggregator.InvokedDataCollectors.ToList()), | ||||||
|
||||||
| new Collection<InvokedDataCollector>(_runDataAggregator.InvokedDataCollectors.ToList()), | |
| _runDataAggregator.InvokedDataCollectors.ToList(), |
Uh oh!
There was an error while loading. Please reload this page.