-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into project/aot-trimming/building
* dev: Bump Microsoft.NET.Test.Sdk from 17.11.0 to 17.11.1 . . v3.2.9 benchmarking alpha release Bump Microsoft.NET.Test.Sdk from 17.10.0 to 17.11.0 . use generic lexer instead of regex lexer use generic lexer instead of regex lexer limit lambdas on Rule.Match remove useless List<UnexpectedTokenError> creation
- Loading branch information
Showing
31 changed files
with
508 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using System; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Toolchains.CsProj; | ||
using expressionparser; | ||
using simpleExpressionParser; | ||
using sly.parser; | ||
using sly.parser.generator; | ||
using ExpressionToken = simpleExpressionParser.ExpressionToken; | ||
|
||
namespace benchCurrent | ||
{ | ||
|
||
[MemoryDiagnoser] | ||
|
||
[Config(typeof(Config))] | ||
public class SimpleExpressionBench | ||
{ | ||
|
||
|
||
private class Config : ManualConfig | ||
{ | ||
public Config() | ||
{ | ||
var baseJob = Job.MediumRun.With(CsProjCoreToolchain.NetCoreApp70); | ||
} | ||
} | ||
|
||
private Parser<ExpressionToken, double> BenchedParser; | ||
private Parser<GenericExpressionToken, double> BenchedGenericParser; | ||
|
||
private string content = ""; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
Console.WriteLine(("SETUP")); | ||
content = "1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20"; | ||
|
||
SimpleExpressionParser p = new SimpleExpressionParser(); | ||
var builder = new ParserBuilder<ExpressionToken, double>(); | ||
|
||
var result = builder.BuildParser(p, ParserType.EBNF_LL_RECURSIVE_DESCENT, "root"); | ||
|
||
if (result.IsError) | ||
{ | ||
result.Errors.ForEach(x => Console.WriteLine(x.Message)); | ||
Environment.Exit(1); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("parser ok"); | ||
BenchedParser = result.Result; | ||
} | ||
|
||
GenericSimpleExpressionParser gp = new GenericSimpleExpressionParser(); | ||
var genericbuilder = new ParserBuilder<GenericExpressionToken, double>(); | ||
|
||
var genericresult = genericbuilder.BuildParser(gp, ParserType.EBNF_LL_RECURSIVE_DESCENT, "root"); | ||
|
||
if (genericresult.IsError) | ||
{ | ||
genericresult.Errors.ForEach(x => Console.WriteLine(x.Message)); | ||
Environment.Exit(2); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("parser ok"); | ||
BenchedGenericParser = genericresult.Result; | ||
} | ||
} | ||
|
||
|
||
|
||
[Benchmark] | ||
|
||
public void TestExpressionRegex() | ||
{ | ||
if (BenchedParser == null) | ||
{ | ||
Console.WriteLine("regex parser is null"); | ||
} | ||
else | ||
{ | ||
for (int i = 0; i < 50; i++) | ||
{ | ||
var ignored = BenchedParser.Parse(content); | ||
} | ||
} | ||
} | ||
|
||
// [Benchmark] | ||
|
||
public void TestExpressionGeneric() | ||
{ | ||
if (BenchedGenericParser == null) | ||
{ | ||
Console.WriteLine("generic parser is null"); | ||
} | ||
else | ||
{ | ||
for (int i = 0; i < 50; i++) | ||
{ | ||
var ignored = BenchedGenericParser.Parse(content); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.