Skip to content

Commit

Permalink
bench: add more analyze benchmarks (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meir017 authored Nov 8, 2023
1 parent 3d49dce commit 1608c95
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,35 @@ namespace FluentAssertions.Analyzers.BenchmarkTests
[JsonExporter]
public class FluentAssertionsBenchmarks
{
private CompilationWithAnalyzers MinimalCompiliation;
private CompilationWithAnalyzers MinimalCompilationWithAnalyzers_ObjectStatement;
private CompilationWithAnalyzers SmallCompilationWithAnalyzers_StringAssertions;

[GlobalSetup]
public async Task GlobalSetup()
{
MinimalCompiliation = await CreateCompilationFromAsync(GenerateCode.ObjectStatement("actual.Should().Equals(expected);"));
MinimalCompilationWithAnalyzers_ObjectStatement = await CreateCompilationFromAsync(GenerateCode.ObjectStatement("actual.Should().Equals(expected);"));
SmallCompilationWithAnalyzers_StringAssertions = await CreateCompilationFromAsync(
GenerateCode.StringAssertion("actual.StartsWith(expected).Should().BeTrue();"),
GenerateCode.StringAssertion("actual.EndsWith(expected).Should().BeTrue();"),
GenerateCode.StringAssertion("actual.Should().NotBeNull().And.NotBeEmpty();"),
GenerateCode.StringAssertion("string.IsNullOrEmpty(actual).Should().BeTrue();"),
GenerateCode.StringAssertion("string.IsNullOrEmpty(actual).Should().BeFalse();"),
GenerateCode.StringAssertion("string.IsNullOrWhiteSpace(actual).Should().BeTrue();"),
GenerateCode.StringAssertion("string.IsNullOrWhiteSpace(actual).Should().BeFalse();"),
GenerateCode.StringAssertion("actual.Length.Should().Be(k);")
);
}

[Benchmark]
public Task MinimalCompilation()
public Task MinimalCompilation_SingleSource_ObjectStatement_Analyzing()
{
return MinimalCompiliation.GetAnalyzerDiagnosticsAsync();
return MinimalCompilationWithAnalyzers_ObjectStatement.GetAnalyzerDiagnosticsAsync();
}

[Benchmark]
public Task SmallCompilation_MultipleSources_StringAssertions_Analyzing()
{
return SmallCompilationWithAnalyzers_StringAssertions.GetAnalyzerDiagnosticsAsync();
}

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

0 comments on commit 1608c95

Please sign in to comment.