Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/Grok.Net.sln → Grok.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28922.388
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grok.Net", "Grok.Net\Grok.Net.csproj", "{80980CE7-4509-4CBC-BEE7-E3DFD2213AE5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grok.Net", ".\src\Grok.Net\Grok.Net.csproj", "{80980CE7-4509-4CBC-BEE7-E3DFD2213AE5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A5D8C62F-3561-425E-A210-190DCA2077C9}"
ProjectSection(SolutionItems) = preProject
..\build.cake = ..\build.cake
..\build.ps1 = ..\build.ps1
..\build.sh = ..\build.sh
build.cake = build.cake
build.ps1 = build.ps1
build.sh = build.sh
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grok.Net.Tests", "Grok.Net.Tests\Grok.Net.Tests.csproj", "{F7A8D826-C853-4AB6-9DB9-EFD3D7C11D12}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grok.Net.Tests", ".\src\Grok.Net.Tests\Grok.Net.Tests.csproj", "{F7A8D826-C853-4AB6-9DB9-EFD3D7C11D12}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmark", ".\benchmark\Benchmark.csproj", "{CF95387B-9D24-4AF1-9371-45BF8BAC6334}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -28,6 +30,10 @@ Global
{F7A8D826-C853-4AB6-9DB9-EFD3D7C11D12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7A8D826-C853-4AB6-9DB9-EFD3D7C11D12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7A8D826-C853-4AB6-9DB9-EFD3D7C11D12}.Release|Any CPU.Build.0 = Release|Any CPU
{CF95387B-9D24-4AF1-9371-45BF8BAC6334}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF95387B-9D24-4AF1-9371-45BF8BAC6334}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF95387B-9D24-4AF1-9371-45BF8BAC6334}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF95387B-9D24-4AF1-9371-45BF8BAC6334}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
22 changes: 22 additions & 0 deletions benchmark/Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\Grok.Net\Grok.Net.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Patterns\grok-custom-patterns">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
54 changes: 54 additions & 0 deletions benchmark/ParseBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using BenchmarkDotNet.Attributes;
using GrokNet;

namespace Benchmark
{
[MemoryDiagnoser]
public class ParseBenchmark
{
private static readonly Grok _grokEmpty = new Grok("");
private static readonly Grok _grokLog = new Grok("%{MONTHDAY:month}-%{MONTHDAY:day}-%{MONTHDAY:year} %{TIME:timestamp};%{WORD:id};%{LOGLEVEL:loglevel};%{WORD:func};%{GREEDYDATA:msg}");
private static readonly Grok _grokCustom = new Grok("%{ZIPCODE:zipcode}:%{EMAILADDRESS:email}");

[Benchmark]
public void Empty()
{
_ = _grokEmpty.Parse("");
}

[Benchmark]
public void Custom()
{
_ = _grokCustom.Parse("06590:[email protected]");
}

[Benchmark]
public void Log()
{
_ = _grokLog.Parse(@"06-21-19 21:00:13:589241;15;INFO;main;DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165
06-21-19 21:00:13:589265;156;WARN;main;DECODED: 775233900043 EMPTY DISTANCE: --------");
}

[Benchmark]
public void EmptyLocal()
{
Grok grokEmptyLocal = new Grok("");
_ = grokEmptyLocal.Parse("");
}

[Benchmark]
public void CustomLocal()
{
Grok grokCustomLocal = new Grok("%{ZIPCODE:zipcode}:%{EMAILADDRESS:email}");
_ = grokCustomLocal.Parse("06590:[email protected]");
}

[Benchmark]
public void LogLocal()
{
Grok grokLogLocal = new Grok("%{MONTHDAY:month}-%{MONTHDAY:day}-%{MONTHDAY:year} %{TIME:timestamp};%{WORD:id};%{LOGLEVEL:loglevel};%{WORD:func};%{GREEDYDATA:msg}");
_ = grokLogLocal.Parse(@"06-21-19 21:00:13:589241;15;INFO;main;DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165
06-21-19 21:00:13:589265;156;WARN;main;DECODED: 775233900043 EMPTY DISTANCE: --------");
}
}
}
1 change: 1 addition & 0 deletions benchmark/Patterns/grok-custom-patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ZIPCODE [1-9]{1}[0-9]{2}\s{0,1}[0-9]{3}
9 changes: 9 additions & 0 deletions benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using BenchmarkDotNet.Running;

namespace Benchmark
{
public class Program
{
private static void Main() => BenchmarkRunner.Run<ParseBenchmark>();
}
}