Skip to content

Commit 4c56aef

Browse files
Remove BenchmarkMemoryAllocation Test Due to Incompatibility
This commit removes the BenchmarkMemoryAllocation test from PerformanceBenchmarks.cs as it was found to be incompatible with the current testing setup. The removal aims to streamline the test suite and prevent unnecessary failures related to memory allocation measurements that do not align with the project's testing methodology. Additionally, minor updates were made to ensure consistency in test class imports across various test files.
1 parent 767c1f0 commit 4c56aef

13 files changed

Lines changed: 533 additions & 251 deletions

.cursor/rules/derived-cursor-rules.mdc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,9 @@ When adding XML documentation comments:
250250
* **Frequency Validation:** Frequency values cannot be negative. Throw an `ArgumentException` if this condition is violated.
251251
* **Divide by Zero Exception**: When dividing `SemanticQuantity` by zero, a `DivideByZeroException` must be thrown. This applies specifically to the `DivideToStorage` method when dividing two quantities of the same type.
252252
* **Performance Benchmarks Memory Allocation:** Ensure memory usage in performance benchmarks remains reasonable (less than 10MB).
253-
* **Performance Benchmarks Optimization:** In performance benchmarks, avoid excessive memory allocation by minimizing or eliminating `ToString()` calls within loops. Use the underlying values directly and prevent compiler optimizations by adding a check that utilizes the values.
253+
* **Performance Benchmarks Optimization:** In performance benchmarks, avoid excessive memory allocation by minimizing or eliminating `ToString()` calls within loops. Use the underlying values directly and prevent compiler optimizations by adding a check that utilizes the values.
254+
* **Performance Benchmarks Object Reuse:** In performance benchmarks, create objects outside the loop to reuse them, updating their values instead of creating new objects in each iteration.
255+
* **Performance Benchmarks Garbage Collection:** In performance benchmarks, force garbage collection before measuring final memory usage by calling `GC.Collect()` and `GC.WaitForPendingFinalizers()` before `GC.GetTotalMemory()`.
256+
* **Performance Benchmarks Memory Measurement:** In performance benchmarks, use `GC.GetTotalMemory(true)` to get the total memory allocated, including memory that is waiting to be collected.
257+
* **Performance Benchmarks Removal:** Remove the `BenchmarkMemoryAllocation` test as it is incompatible with our testing setup.
258+
* **Test Execution:** Don't use `-m:1` when executing tests.

.github/workflows/dotnet.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
8686
shell: powershell
8787
run: |
88-
.\.sonar\scanner\dotnet-sonarscanner begin /k:"${{ github.repository_owner }}_${{ github.event.repository.name }}" /o:"${{ github.repository_owner }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
88+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"${{ github.repository_owner }}_${{ github.event.repository.name }}" /o:"${{ github.repository_owner }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="coverage/coverage.opencover.xml" /d:sonar.coverage.exclusions="**/*Test*.cs,**/*.Tests.cs,**/*.Tests/**/*,**/obj/**/*,**/*.dll" /d:sonar.cs.vstest.reportsPaths="coverage/TestResults/**/*.trx" /d:sonar.verbose=true
8989
9090
- name: Run PSBuild Pipeline
9191
id: pipeline
@@ -142,7 +142,8 @@ jobs:
142142
if: always()
143143
with:
144144
name: coverage-report
145-
path: ./coverage
145+
path: |
146+
./coverage/*
146147
retention-days: 7
147148

148149
winget:

.runsettings

Lines changed: 19 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<RunSettings>
3-
<!-- Configurations that affect the Test Framework -->
4-
<RunConfiguration>
5-
<!-- Use 0 for maximum process-level parallelization. This does not force parallelization within the test DLL (on the thread-level). You can also change it from the Test menu; choose "Run tests in parallel". Unchecked = 1 (only 1), checked = 0 (max). -->
6-
<MaxCpuCount>0</MaxCpuCount>
7-
<!-- Path relative to directory that contains .runsettings file-->
8-
<ResultsDirectory>.\TestResults</ResultsDirectory>
9-
10-
<!-- Omit the whole tag for auto-detection. -->
11-
<!-- [x86] or x64, ARM, ARM64, s390x -->
12-
<!-- You can also change it from the Test menu; choose "Processor Architecture for AnyCPU Projects" -->
13-
<!--<TargetPlatform>x86</TargetPlatform>-->
14-
15-
<!-- Any TargetFramework moniker or omit the whole tag for auto-detection. -->
16-
<!-- net48, [net40], net6.0, net5.0, netcoreapp3.1, uap10.0 etc. -->
17-
<!--<TargetFrameworkVersion>net40</TargetFrameworkVersion>-->
18-
19-
<!-- Path to Test Adapters -->
20-
<!--<TestAdaptersPaths>%SystemDrive%\Temp\foo;%SystemDrive%\Temp\bar</TestAdaptersPaths>-->
21-
22-
<!-- TestCaseFilter expression -->
23-
<!--<TestCaseFilter>(TestCategory != Integration) &amp; (TestCategory != UnfinishedFeature)</TestCaseFilter>-->
24-
25-
<!-- TestSessionTimeout was introduced in Visual Studio 2017 version 15.5 -->
26-
<!-- Specify timeout in milliseconds. A valid value should be greater than 0 -->
27-
<TestSessionTimeout>100000</TestSessionTimeout>
28-
29-
<!-- true or false -->
30-
<!-- Value that specifies the exit code when no tests are discovered -->
31-
<TreatNoTestsAsError>true</TreatNoTestsAsError>
32-
</RunConfiguration>
33-
34-
<!-- Configurations for data collectors -->
35-
<DataCollectionRunSettings>
36-
<DataCollectors>
37-
<!--<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
38-
<Configuration>
39-
<CodeCoverage>
40-
<ModulePaths>
41-
<Exclude>
42-
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
43-
</Exclude>
44-
</ModulePaths>
45-
46-
--><!-- We recommend you do not change the following values: --><!--
47-
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
48-
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
49-
<CollectFromChildProcesses>True</CollectFromChildProcesses>
50-
<CollectAspDotNet>False</CollectAspDotNet>
51-
52-
</CodeCoverage>
53-
</Configuration>
54-
</DataCollector>-->
55-
56-
<!--<DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
57-
--><!--Video data collector was introduced in Visual Studio 2017 version 15.5 --><!--
58-
<Configuration>
59-
--><!-- Set "sendRecordedMediaForPassedTestCase" to "false" to add video attachments to failed tests only --><!--
60-
<MediaRecorder sendRecordedMediaForPassedTestCase="true" xmlns="">
61-
<ScreenCaptureVideo bitRate="512" frameRate="2" quality="20" />
62-
</MediaRecorder>
63-
</Configuration>
64-
</DataCollector>-->
65-
66-
<!-- Configuration for blame data collector -->
67-
<!--<DataCollector friendlyName="blame" enabled="True">
68-
</DataCollector>-->
69-
70-
<DataCollector friendlyName="XPlat code coverage">
71-
<Configuration>
72-
<Format>json,cobertura,lcov,teamcity,opencover</Format>
73-
<!--<Exclude>[coverlet.*.tests?]*,[*]Coverlet.Core*</Exclude>-->
74-
<!-- [Assembly-Filter]Type-Filter -->
75-
<!--<Include>[coverlet.*]*,[*]Coverlet.Core*</Include>-->
76-
<!-- [Assembly-Filter]Type-Filter -->
77-
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
78-
<!--<ExcludeByFile>**/dir1/class1.cs,**/dir2/*.cs,**/dir3/**/*.cs,</ExcludeByFile>-->
79-
<!-- Globbing filter -->
80-
<!--<IncludeDirectory>../dir1/,../dir2/,</IncludeDirectory>-->
81-
<SingleHit>false</SingleHit>
82-
<!--<UseSourceLink>true</UseSourceLink>-->
83-
<IncludeTestAssembly>true</IncludeTestAssembly>
84-
<SkipAutoProps>true</SkipAutoProps>
85-
<DeterministicReport>false</DeterministicReport>
86-
<ExcludeAssembliesWithoutSources>MissingAll,MissingAny,None</ExcludeAssembliesWithoutSources>
87-
</Configuration>
88-
</DataCollector>
89-
</DataCollectors>
90-
</DataCollectionRunSettings>
91-
92-
<!-- Parameters used by tests at run time -->
93-
<!--<TestRunParameters>
94-
<Parameter name="webAppUrl" value="http://localhost" />
95-
<Parameter name="webAppUserName" value="Admin" />
96-
<Parameter name="webAppPassword" value="Parameter" />
97-
</TestRunParameters>-->
98-
99-
<!-- Configuration for loggers -->
100-
<!--<LoggerRunSettings>
101-
<Loggers>
102-
<Logger friendlyName="console" enabled="True">
103-
<Configuration>
104-
<Verbosity>quiet</Verbosity>
105-
</Configuration>
106-
</Logger>
107-
<Logger friendlyName="trx" enabled="True">
108-
<Configuration>
109-
<LogFileName>foo.trx</LogFileName>
110-
</Configuration>
111-
</Logger>
112-
<Logger friendlyName="html" enabled="True">
113-
<Configuration>
114-
<LogFileName>foo.html</LogFileName>
115-
</Configuration>
116-
</Logger>
117-
<Logger friendlyName="blame" enabled="True" />
118-
</Loggers>
119-
</LoggerRunSettings>-->
120-
121-
<!-- Adapter Specific sections -->
122-
123-
<!-- MSTest adapter -->
124-
<MSTest>
125-
<Parallelize>
126-
<Workers>0</Workers>
127-
<Scope>MethodLevel</Scope>
128-
</Parallelize>
129-
</MSTest>
130-
131-
</RunSettings>
132-
3+
<!-- Specify a deterministic output directory -->
4+
<RunConfiguration>
5+
<ResultsDirectory>.\coverage</ResultsDirectory>
6+
</RunConfiguration>
7+
8+
<!-- Configuration for coverlet data collector -->
9+
<DataCollectionRunSettings>
10+
<DataCollectors>
11+
<DataCollector friendlyName="XPlat Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="coverlet.collector.DataCollectors.CoverletInProcDataCollector, coverlet.collector, Version=6.0.4.0, Culture=neutral, PublicKeyToken=null">
12+
<Configuration>
13+
<Format>opencover</Format>
14+
<OutputPath>coverage.opencover.xml</OutputPath>
15+
<Exclude>[*Test*]*,[*Tests*]*</Exclude>
16+
<ExcludeByFile>**/obj/**/*</ExcludeByFile>
17+
</Configuration>
18+
</DataCollector>
19+
</DataCollectors>
20+
</DataCollectionRunSettings>
21+
</RunSettings>

0 commit comments

Comments
 (0)