-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
997 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Security.Cryptography; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Exporters.Csv; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Toolchains.CsProj; | ||
using sly.lexer; | ||
using sly.lexer.fsm; | ||
using sly.parser; | ||
using sly.parser.generator; | ||
using sly.buildresult; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using BenchmarkDotNet.Analysers; | ||
using BenchmarkDotNet.Toolchains.InProcess; | ||
|
||
|
||
namespace bench | ||
{ | ||
|
||
[MemoryDiagnoser] | ||
|
||
[Config(typeof(Config))] | ||
public class Bench | ||
{ | ||
|
||
|
||
private class Config : ManualConfig | ||
{ | ||
public Config() | ||
{ | ||
var baseJob = Job.MediumRun.With(CsProjCoreToolchain.Current.Value); | ||
Add(baseJob.WithNuGet("sly", "2.2.5.1").WithId("2.2.5.1")); | ||
Add(baseJob.WithNuGet("sly", "2.2.5.2").WithId("2.2.5.2")); | ||
Add(EnvironmentAnalyser.Default); | ||
Add(baseJob.WithNuGet("sly", "2.2.5.3").WithId("2.2.5.3")); | ||
Add(baseJob.WithNuGet("sly", "2.3.0.1").WithId("2.3.0.1")); | ||
} | ||
} | ||
|
||
private ILexer<JsonTokenGeneric> BenchedLexer; | ||
|
||
private string content = ""; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
content = File.ReadAllText("test.json"); | ||
|
||
var lexerRes = LexerBuilder.BuildLexer(new BuildResult<ILexer<JsonTokenGeneric>>()); | ||
if (lexerRes != null) | ||
{ | ||
BenchedLexer = lexerRes.Result; | ||
} | ||
} | ||
|
||
[Benchmark] | ||
|
||
public void TestJson() { | ||
var ignored = BenchedLexer.Tokenize(content).ToList(); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
} |
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,22 @@ | ||
using sly.lexer; | ||
|
||
|
||
namespace bench | ||
{ | ||
public enum JsonTokenGeneric | ||
{ | ||
[Lexeme(GenericToken.String)] STRING = 1, | ||
[Lexeme(GenericToken.Double)] DOUBLE = 2, | ||
[Lexeme(GenericToken.Int)] INT = 3, | ||
|
||
[Lexeme(GenericToken.KeyWord, "true", "false")] | ||
BOOLEAN = 4, | ||
[Lexeme(GenericToken.SugarToken, "{")] ACCG = 5, | ||
[Lexeme(GenericToken.SugarToken, "}")] ACCD = 6, | ||
[Lexeme(GenericToken.SugarToken, "[")] CROG = 7, | ||
[Lexeme(GenericToken.SugarToken, "]")] CROD = 8, | ||
[Lexeme(GenericToken.SugarToken, ",")] COMMA = 9, | ||
[Lexeme(GenericToken.SugarToken, ":")] COLON = 10, | ||
[Lexeme(GenericToken.KeyWord, "null")] NULL = 14 | ||
} | ||
} |
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,27 @@ | ||
using System; | ||
using System.IO; | ||
using System.Diagnostics; | ||
using BenchmarkDotNet.Running; | ||
using sly; | ||
using sly.lexer; | ||
using sly.buildresult; | ||
|
||
|
||
|
||
namespace bench | ||
{ | ||
class Program | ||
{ | ||
|
||
private static void BenchJSON() { | ||
|
||
var summary = BenchmarkRunner.Run<Bench>(); | ||
|
||
} | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Hello World!"); | ||
BenchJSON(); | ||
} | ||
} | ||
} |
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" /> | ||
<PackageReference Include="sly" Version="2.2.5.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="test.json" /> | ||
<Content Include="test.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.