Skip to content

Commit

Permalink
Added ToCode benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
carl-andersson-at-westermo committed May 29, 2024
1 parent 8bb323c commit 8f5bb2d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ public class ParsingBenchmarks
{
private string source;

Check warning on line 13 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / Performance regression check

Non-nullable field 'source' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 13 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'source' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 13 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / Performance regression check

Non-nullable field 'source' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
private YangStatement statement;

Check warning on line 14 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / Performance regression check

Non-nullable field 'statement' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 14 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'statement' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 14 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / Performance regression check

Non-nullable field 'statement' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
private IStatement model;

Check warning on line 15 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / Performance regression check

Non-nullable field 'model' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 15 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'model' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 15 in benchmarks/Program.cs

View workflow job for this annotation

GitHub Actions / Performance regression check

Non-nullable field 'model' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

[GlobalSetup]
public void Setup()
{
source = File.ReadAllText("../../../../lin.yang");
statement = Parser.Parse("lin.yang", source);
model = StatementFactory.Create(statement);
}

[Benchmark]
public YangStatement Parse() => Parser.Parse("lin.yang", source);

[Benchmark]
public IStatement SemanticModel() => StatementFactory.Create(statement);

[Benchmark]
public string ToCode() => model.ToCode();
}

internal static class Program
Expand Down

0 comments on commit 8f5bb2d

Please sign in to comment.