Skip to content

Commit 1608c95

Browse files
authored
bench: add more analyze benchmarks (#247)
1 parent 3d49dce commit 1608c95

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/FluentAssertions.Analyzers.BenchmarkTests/FluentAssertionsBenchmarks.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,35 @@ namespace FluentAssertions.Analyzers.BenchmarkTests
1515
[JsonExporter]
1616
public class FluentAssertionsBenchmarks
1717
{
18-
private CompilationWithAnalyzers MinimalCompiliation;
18+
private CompilationWithAnalyzers MinimalCompilationWithAnalyzers_ObjectStatement;
19+
private CompilationWithAnalyzers SmallCompilationWithAnalyzers_StringAssertions;
1920

2021
[GlobalSetup]
2122
public async Task GlobalSetup()
2223
{
23-
MinimalCompiliation = await CreateCompilationFromAsync(GenerateCode.ObjectStatement("actual.Should().Equals(expected);"));
24+
MinimalCompilationWithAnalyzers_ObjectStatement = await CreateCompilationFromAsync(GenerateCode.ObjectStatement("actual.Should().Equals(expected);"));
25+
SmallCompilationWithAnalyzers_StringAssertions = await CreateCompilationFromAsync(
26+
GenerateCode.StringAssertion("actual.StartsWith(expected).Should().BeTrue();"),
27+
GenerateCode.StringAssertion("actual.EndsWith(expected).Should().BeTrue();"),
28+
GenerateCode.StringAssertion("actual.Should().NotBeNull().And.NotBeEmpty();"),
29+
GenerateCode.StringAssertion("string.IsNullOrEmpty(actual).Should().BeTrue();"),
30+
GenerateCode.StringAssertion("string.IsNullOrEmpty(actual).Should().BeFalse();"),
31+
GenerateCode.StringAssertion("string.IsNullOrWhiteSpace(actual).Should().BeTrue();"),
32+
GenerateCode.StringAssertion("string.IsNullOrWhiteSpace(actual).Should().BeFalse();"),
33+
GenerateCode.StringAssertion("actual.Length.Should().Be(k);")
34+
);
2435
}
2536

2637
[Benchmark]
27-
public Task MinimalCompilation()
38+
public Task MinimalCompilation_SingleSource_ObjectStatement_Analyzing()
2839
{
29-
return MinimalCompiliation.GetAnalyzerDiagnosticsAsync();
40+
return MinimalCompilationWithAnalyzers_ObjectStatement.GetAnalyzerDiagnosticsAsync();
41+
}
42+
43+
[Benchmark]
44+
public Task SmallCompilation_MultipleSources_StringAssertions_Analyzing()
45+
{
46+
return SmallCompilationWithAnalyzers_StringAssertions.GetAnalyzerDiagnosticsAsync();
3047
}
3148

3249
private async Task<CompilationWithAnalyzers> CreateCompilationFromAsync(params string[] sources)

0 commit comments

Comments
 (0)