Skip to content

Commit df34e11

Browse files
[tests] update MSBuild performance tests
It's been a while, since I went through and refactored these tests. After seeing a couple build-time regressions in .NET 9, I think it's overdue. Removing test cases that likely won't catch an issue: * `Build_Designer_Change` (less concerned about designer now) * `Build_CSProj_Change` `Build_From_Clean_DontIncludeRestore` would likely catch similar issues as these two, anyway. `Build_XAML_Change_RefAssembly` now uses a `net8.0` class library where `$(ProduceReferenceAssembly)` defaults to `true`. Removed a 500ms addition, that only made sense when we supported both "classic" Xamarin.Android and .NET 6+ projects. Update the time thresholds to be a bit shorter, in general.
1 parent eb5455a commit df34e11

File tree

2 files changed

+10
-74
lines changed

2 files changed

+10
-74
lines changed

tests/MSBuildDeviceIntegration/Tests/PerformanceTest.cs

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ void Profile (ProjectBuilder builder, Action<ProjectBuilder> action, [CallerMemb
5050
Assert.Fail ($"No timeout value found for a key of {caller}");
5151
}
5252

53-
//TODO: Update baselines in MSBuildDeviceIntegration.csv, there is currently a slight performance regression in .NET 6
54-
expected += 500;
55-
5653
action (builder);
5754
var actual = GetDurationFromBinLog (builder);
5855
TestContext.Out.WriteLine($"expected: {expected}ms, actual: {actual}ms");
@@ -203,27 +200,6 @@ public void Build_AndroidAsset_Change ()
203200
}
204201
}
205202

206-
[Test]
207-
[Retry (Retry)]
208-
public void Build_Designer_Change ()
209-
{
210-
var proj = CreateApplicationProject ();
211-
using (var builder = CreateBuilderWithoutLogFile ()) {
212-
builder.Target = "Build";
213-
builder.Build (proj);
214-
builder.AutomaticNuGetRestore = false;
215-
216-
// Change AndroidResource & run SetupDependenciesForDesigner
217-
proj.LayoutMain += $"{Environment.NewLine}<!--comment-->";
218-
proj.Touch ("Resources\\layout\\Main.axml");
219-
var parameters = new [] { "DesignTimeBuild=True", "AndroidUseManagedDesignTimeResourceGenerator=False" };
220-
builder.RunTarget (proj, "SetupDependenciesForDesigner", parameters: parameters);
221-
222-
// Profile AndroidResource change
223-
Profile (builder, b => b.Build (proj));
224-
}
225-
}
226-
227203
[Test]
228204
[Retry (Retry)]
229205
public void Build_JLO_Change ()
@@ -263,43 +239,9 @@ public void Build_AndroidManifest_Change ()
263239
}
264240

265241
[Test]
266-
[Retry (Retry)]
267-
public void Build_CSProj_Change ()
268-
{
269-
var proj = CreateApplicationProject ();
270-
using (var builder = CreateBuilderWithoutLogFile ()) {
271-
builder.Target = "Build";
272-
builder.Build (proj);
273-
builder.AutomaticNuGetRestore = false;
274-
275-
// Profile .csproj change
276-
proj.Sources.Add (new BuildItem ("None", "Foo.txt") {
277-
TextContent = () => "Bar",
278-
});
279-
Profile (builder, b => b.Build (proj));
280-
}
281-
}
282-
283-
static object [] XAML_Change = new object [] {
284-
new object [] {
285-
/* produceReferenceAssembly */ false,
286-
/* install */ false,
287-
},
288-
new object [] {
289-
/* produceReferenceAssembly */ true,
290-
/* install */ false,
291-
},
292-
new object [] {
293-
/* produceReferenceAssembly */ true,
294-
/* install */ true,
295-
},
296-
};
297-
298-
[Test]
299-
[TestCaseSource (nameof (XAML_Change))]
300242
[Category ("UsesDevice")]
301243
[Retry (Retry)]
302-
public void Build_XAML_Change (bool produceReferenceAssembly, bool install)
244+
public void Build_XAML_Change ([Values (true, false)] bool install)
303245
{
304246
if (install) {
305247
AssertCommercialBuild (); // This test will fail without Fast Deployment
@@ -315,8 +257,6 @@ public void Build_XAML_Change (bool produceReferenceAssembly, bool install)
315257
var caller = nameof (Build_XAML_Change);
316258
if (install) {
317259
caller = caller.Replace ("Build", "Install");
318-
} else if (produceReferenceAssembly) {
319-
caller += "_RefAssembly";
320260
}
321261
var app = CreateApplicationProject ();
322262
app.ProjectName = "MyApp";
@@ -332,7 +272,7 @@ public void Build_XAML_Change (bool produceReferenceAssembly, bool install)
332272
var lib = new DotNetStandard {
333273
ProjectName = "MyLibrary",
334274
Sdk = "Microsoft.NET.Sdk",
335-
TargetFramework = "netstandard2.0",
275+
TargetFramework = "net8.0", // Vanilla project
336276
Sources = {
337277
new BuildItem.Source ("Bar.cs") {
338278
TextContent = () => "public class Bar { public Bar () { System.Console.WriteLine (" + count++ + "); } }"
@@ -345,7 +285,6 @@ public void Build_XAML_Change (bool produceReferenceAssembly, bool install)
345285
KnownPackages.XamarinForms,
346286
}
347287
};
348-
lib.SetProperty ("ProduceReferenceAssembly", produceReferenceAssembly.ToString ());
349288
app.References.Add (new BuildItem.ProjectReference ($"..\\{lib.ProjectName}\\{lib.ProjectName}.csproj", lib.ProjectName, lib.ProjectGuid));
350289

351290
using (var libBuilder = CreateBuilderWithoutLogFile (Path.Combine (path, lib.ProjectName), isApp: false))

tests/msbuild-times-reference/MSBuildDeviceIntegration.csv

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
Test Name,Time in ms (int)
44
# Data
55
Build_From_Clean_DontIncludeRestore,13000
6-
Build_No_Changes,2500
7-
Build_CSharp_Change,4000
8-
Build_AndroidResource_Change,3250
9-
Build_AndroidAsset_Change,10000
6+
Build_No_Changes,2250
7+
Build_CSharp_Change,3500
8+
Build_AndroidResource_Change,2250
9+
Build_AndroidAsset_Change,6500
1010
Build_AndroidManifest_Change,4500
11-
Build_Designer_Change,3000
12-
Build_JLO_Change,10000
13-
Build_CSProj_Change,12500
14-
Build_XAML_Change,7400
15-
Build_XAML_Change_RefAssembly,4000
16-
Install_CSharp_Change,4500
17-
Install_XAML_Change,5000
11+
Build_JLO_Change,4500
12+
Build_XAML_Change,3000
13+
Install_CSharp_Change,4000
14+
Install_XAML_Change,3750

0 commit comments

Comments
 (0)