-
Notifications
You must be signed in to change notification settings - Fork 319
Нухов Руслан #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dobtyk
wants to merge
19
commits into
kontur-courses:master
Choose a base branch
from
Dobtyk:Markdown
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Нухов Руслан #254
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ce5fffa
Classwork
Dobtyk 502a801
Initial structure
Dobtyk cb80f63
Revert "Classwork"
Dobtyk 6ac0790
Refactoring
Dobtyk 7218197
Parser
Dobtyk 8753d40
HtmlRenderer
Dobtyk 570f116
Refactoring and added mdTests
Dobtyk 3f4d06f
Refactoring
Dobtyk 1b854a4
Refactoring
Dobtyk 1c57630
Cleanup
Dobtyk ebf6fa2
Refactoring HtmlRenderer
Dobtyk 76fc09e
Refactoring parser
Dobtyk ae8c4bf
Refactoring
Dobtyk e2fd38a
Performance test
Dobtyk 01114f2
Refactoring
Dobtyk 78bcec4
Refactoring
Dobtyk 52ecd3c
Added Link
Dobtyk d0e34b8
Refactoring
Dobtyk 332b089
Refactroing
Dobtyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...et.Artifacts/results/BenchmarkMarkdown.MarkdownParserBenchmark-report-github.md
This file contains hidden or 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,16 @@ | ||
| ``` | ||
|
|
||
| BenchmarkDotNet v0.15.6, Windows 10 (10.0.19045.6216/22H2/2022Update) | ||
| AMD Ryzen 9 5900HX with Radeon Graphics 3.30GHz, 1 CPU, 16 logical and 8 physical cores | ||
| .NET SDK 9.0.306 | ||
| [Host] : .NET 9.0.10 (9.0.10, 9.0.1025.47515), X64 RyuJIT x86-64-v3 | ||
| DefaultJob : .NET 9.0.10 (9.0.10, 9.0.1025.47515), X64 RyuJIT x86-64-v3 | ||
|
|
||
|
|
||
| ``` | ||
| | Method | TextSizeMultiplier | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | | ||
| |------- |------------------- |-------------:|------------:|------------:|------------:|-----------:|----------:|--------------:| | ||
| | **Parse** | **1** | **294.4 μs** | **5.65 μs** | **5.55 μs** | **124.5117** | **2.4414** | **-** | **1017.81 KB** | | ||
| | **Parse** | **10** | **3,172.7 μs** | **10.81 μs** | **9.59 μs** | **1363.2813** | **187.5000** | **11.7188** | **11146.04 KB** | | ||
| | **Parse** | **100** | **36,115.6 μs** | **120.37 μs** | **100.52 μs** | **12333.3333** | **333.3333** | **133.3333** | **101203 KB** | | ||
| | **Parse** | **1000** | **335,972.8 μs** | **6,497.19 μs** | **7,482.17 μs** | **127000.0000** | **33000.0000** | **4000.0000** | **1011847.79 KB** | |
5 changes: 5 additions & 0 deletions
5
...wn/BenchmarkDotNet.Artifacts/results/BenchmarkMarkdown.MarkdownParserBenchmark-report.csv
This file contains hidden or 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,5 @@ | ||
| Method;Job;AnalyzeLaunchVariance;EvaluateOverhead;MaxAbsoluteError;MaxRelativeError;MinInvokeCount;MinIterationTime;OutlierMode;Affinity;EnvironmentVariables;Jit;LargeAddressAware;Platform;PowerPlanMode;Runtime;AllowVeryLargeObjects;Concurrent;CpuGroups;Force;HeapAffinitizeMask;HeapCount;NoAffinitize;RetainVm;Server;Arguments;BuildConfiguration;Clock;EngineFactory;NuGetReferences;Toolchain;IsMutator;InvocationCount;IterationCount;IterationTime;LaunchCount;MaxIterationCount;MaxWarmupIterationCount;MemoryRandomization;MinIterationCount;MinWarmupIterationCount;RunStrategy;UnrollFactor;WarmupCount;TextSizeMultiplier;Mean;Error;StdDev;Gen0;Gen1;Gen2;Allocated | ||
| Parse;DefaultJob;False;Default;Default;Default;Default;Default;Default;1111111111111111;Empty;RyuJit;Default;X64;8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;.NET 9.0;False;True;False;True;Default;Default;False;False;False;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;16;Default;1;294.4 μs;5.65 μs;5.55 μs;124.5117;2.4414;0.0000;1017.81 KB | ||
| Parse;DefaultJob;False;Default;Default;Default;Default;Default;Default;1111111111111111;Empty;RyuJit;Default;X64;8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;.NET 9.0;False;True;False;True;Default;Default;False;False;False;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;16;Default;10;"3,172.7 μs";10.81 μs;9.59 μs;1363.2813;187.5000;11.7188;11146.04 KB | ||
| Parse;DefaultJob;False;Default;Default;Default;Default;Default;Default;1111111111111111;Empty;RyuJit;Default;X64;8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;.NET 9.0;False;True;False;True;Default;Default;False;False;False;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;16;Default;100;"36,115.6 μs";120.37 μs;100.52 μs;12333.3333;333.3333;133.3333;101203 KB | ||
| Parse;DefaultJob;False;Default;Default;Default;Default;Default;Default;1111111111111111;Empty;RyuJit;Default;X64;8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;.NET 9.0;False;True;False;True;Default;Default;False;False;False;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;16;Default;1000;"335,972.8 μs";"6,497.19 μs";"7,482.17 μs";127000.0000;33000.0000;4000.0000;1011847.79 KB |
33 changes: 33 additions & 0 deletions
33
...n/BenchmarkDotNet.Artifacts/results/BenchmarkMarkdown.MarkdownParserBenchmark-report.html
This file contains hidden or 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,33 @@ | ||
| <!DOCTYPE html> | ||
| <html lang='en'> | ||
| <head> | ||
| <meta charset='utf-8' /> | ||
| <title>BenchmarkMarkdown.MarkdownParserBenchmark-20251115-183056</title> | ||
|
|
||
| <style type="text/css"> | ||
| table { border-collapse: collapse; display: block; width: 100%; overflow: auto; } | ||
| td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; } | ||
| tr { background-color: #fff; border-top: 1px solid #ccc; } | ||
| tr:nth-child(even) { background: #f8f8f8; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <pre><code> | ||
| BenchmarkDotNet v0.15.6, Windows 10 (10.0.19045.6216/22H2/2022Update) | ||
| AMD Ryzen 9 5900HX with Radeon Graphics 3.30GHz, 1 CPU, 16 logical and 8 physical cores | ||
| .NET SDK 9.0.306 | ||
| [Host] : .NET 9.0.10 (9.0.10, 9.0.1025.47515), X64 RyuJIT x86-64-v3 | ||
| DefaultJob : .NET 9.0.10 (9.0.10, 9.0.1025.47515), X64 RyuJIT x86-64-v3 | ||
| </code></pre> | ||
| <pre><code></code></pre> | ||
|
|
||
| <table> | ||
| <thead><tr><th>Method</th><th>TextSizeMultiplier</th><th>Mean </th><th>Error</th><th>StdDev</th><th>Gen0 </th><th>Gen1</th><th>Gen2</th><th>Allocated</th> | ||
| </tr> | ||
| </thead><tbody><tr><td>Parse</td><td>1</td><td>294.4 μs</td><td>5.65 μs</td><td>5.55 μs</td><td>124.5117</td><td>2.4414</td><td>-</td><td>1017.81 KB</td> | ||
| </tr><tr><td>Parse</td><td>10</td><td>3,172.7 μs</td><td>10.81 μs</td><td>9.59 μs</td><td>1363.2813</td><td>187.5000</td><td>11.7188</td><td>11146.04 KB</td> | ||
| </tr><tr><td>Parse</td><td>100</td><td>36,115.6 μs</td><td>120.37 μs</td><td>100.52 μs</td><td>12333.3333</td><td>333.3333</td><td>133.3333</td><td>101203 KB</td> | ||
| </tr><tr><td>Parse</td><td>1000</td><td>335,972.8 μs</td><td>6,497.19 μs</td><td>7,482.17 μs</td><td>127000.0000</td><td>33000.0000</td><td>4000.0000</td><td>1011847.79 KB</td> | ||
| </tr></tbody></table> | ||
| </body> | ||
| </html> |
16 changes: 16 additions & 0 deletions
16
...enchmarkDotNet.Artifacts/results/BenchmarkMarkdown.MdBenchmark-report-github.md
This file contains hidden or 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,16 @@ | ||
| ``` | ||
|
|
||
| BenchmarkDotNet v0.15.6, Windows 10 (10.0.19045.6216/22H2/2022Update) | ||
| AMD Ryzen 9 5900HX with Radeon Graphics 3.30GHz, 1 CPU, 16 logical and 8 physical cores | ||
| .NET SDK 9.0.306 | ||
| [Host] : .NET 9.0.10 (9.0.10, 9.0.1025.47515), X64 RyuJIT x86-64-v3 | ||
| DefaultJob : .NET 9.0.10 (9.0.10, 9.0.1025.47515), X64 RyuJIT x86-64-v3 | ||
|
|
||
|
|
||
| ``` | ||
| | Method | TextSizeMultiplier | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | | ||
| |------- |------------------- |-------------:|-------------:|-------------:|------------:|-----------:|----------:|-----------:| | ||
| | **Render** | **1** | **500.1 μs** | **9.93 μs** | **17.13 μs** | **150.3906** | **2.9297** | **-** | **1.2 MB** | | ||
| | **Render** | **10** | **5,322.4 μs** | **105.85 μs** | **273.24 μs** | **1492.1875** | **195.3125** | **-** | **11.95 MB** | | ||
| | **Render** | **100** | **56,038.2 μs** | **1,117.32 μs** | **1,566.33 μs** | **14900.0000** | **500.0000** | **200.0000** | **119.28 MB** | | ||
| | **Render** | **1000** | **576,250.8 μs** | **11,258.63 μs** | **11,561.78 μs** | **149000.0000** | **31000.0000** | **4000.0000** | **1192.54 MB** | |
5 changes: 5 additions & 0 deletions
5
...chmarkMarkdown/BenchmarkDotNet.Artifacts/results/BenchmarkMarkdown.MdBenchmark-report.csv
This file contains hidden or 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,5 @@ | ||
| Method;Job;AnalyzeLaunchVariance;EvaluateOverhead;MaxAbsoluteError;MaxRelativeError;MinInvokeCount;MinIterationTime;OutlierMode;Affinity;EnvironmentVariables;Jit;LargeAddressAware;Platform;PowerPlanMode;Runtime;AllowVeryLargeObjects;Concurrent;CpuGroups;Force;HeapAffinitizeMask;HeapCount;NoAffinitize;RetainVm;Server;Arguments;BuildConfiguration;Clock;EngineFactory;NuGetReferences;Toolchain;IsMutator;InvocationCount;IterationCount;IterationTime;LaunchCount;MaxIterationCount;MaxWarmupIterationCount;MemoryRandomization;MinIterationCount;MinWarmupIterationCount;RunStrategy;UnrollFactor;WarmupCount;TextSizeMultiplier;Mean;Error;StdDev;Gen0;Gen1;Gen2;Allocated | ||
| Render;DefaultJob;False;Default;Default;Default;Default;Default;Default;1111111111111111;Empty;RyuJit;Default;X64;8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;.NET 9.0;False;True;False;True;Default;Default;False;False;False;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;16;Default;1;500.1 μs;9.93 μs;17.13 μs;150.3906;2.9297;0.0000;1.2 MB | ||
| Render;DefaultJob;False;Default;Default;Default;Default;Default;Default;1111111111111111;Empty;RyuJit;Default;X64;8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;.NET 9.0;False;True;False;True;Default;Default;False;False;False;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;16;Default;10;"5,322.4 μs";105.85 μs;273.24 μs;1492.1875;195.3125;0.0000;11.95 MB | ||
| Render;DefaultJob;False;Default;Default;Default;Default;Default;Default;1111111111111111;Empty;RyuJit;Default;X64;8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;.NET 9.0;False;True;False;True;Default;Default;False;False;False;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;16;Default;100;"56,038.2 μs";"1,117.32 μs";"1,566.33 μs";14900.0000;500.0000;200.0000;119.28 MB | ||
| Render;DefaultJob;False;Default;Default;Default;Default;Default;Default;1111111111111111;Empty;RyuJit;Default;X64;8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;.NET 9.0;False;True;False;True;Default;Default;False;False;False;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;Default;16;Default;1000;"576,250.8 μs";"11,258.63 μs";"11,561.78 μs";149000.0000;31000.0000;4000.0000;1192.54 MB |
33 changes: 33 additions & 0 deletions
33
...hmarkMarkdown/BenchmarkDotNet.Artifacts/results/BenchmarkMarkdown.MdBenchmark-report.html
This file contains hidden or 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,33 @@ | ||
| <!DOCTYPE html> | ||
| <html lang='en'> | ||
| <head> | ||
| <meta charset='utf-8' /> | ||
| <title>BenchmarkMarkdown.MdBenchmark-20251130-183500</title> | ||
|
|
||
| <style type="text/css"> | ||
| table { border-collapse: collapse; display: block; width: 100%; overflow: auto; } | ||
| td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; } | ||
| tr { background-color: #fff; border-top: 1px solid #ccc; } | ||
| tr:nth-child(even) { background: #f8f8f8; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <pre><code> | ||
| BenchmarkDotNet v0.15.6, Windows 10 (10.0.19045.6216/22H2/2022Update) | ||
| AMD Ryzen 9 5900HX with Radeon Graphics 3.30GHz, 1 CPU, 16 logical and 8 physical cores | ||
| .NET SDK 9.0.306 | ||
| [Host] : .NET 9.0.10 (9.0.10, 9.0.1025.47515), X64 RyuJIT x86-64-v3 | ||
| DefaultJob : .NET 9.0.10 (9.0.10, 9.0.1025.47515), X64 RyuJIT x86-64-v3 | ||
| </code></pre> | ||
| <pre><code></code></pre> | ||
|
|
||
| <table> | ||
| <thead><tr><th>Method</th><th>TextSizeMultiplier</th><th>Mean </th><th>Error </th><th>StdDev</th><th>Gen0 </th><th>Gen1</th><th>Gen2</th><th>Allocated</th> | ||
| </tr> | ||
| </thead><tbody><tr><td>Render</td><td>1</td><td>500.1 μs</td><td>9.93 μs</td><td>17.13 μs</td><td>150.3906</td><td>2.9297</td><td>-</td><td>1.2 MB</td> | ||
| </tr><tr><td>Render</td><td>10</td><td>5,322.4 μs</td><td>105.85 μs</td><td>273.24 μs</td><td>1492.1875</td><td>195.3125</td><td>-</td><td>11.95 MB</td> | ||
| </tr><tr><td>Render</td><td>100</td><td>56,038.2 μs</td><td>1,117.32 μs</td><td>1,566.33 μs</td><td>14900.0000</td><td>500.0000</td><td>200.0000</td><td>119.28 MB</td> | ||
| </tr><tr><td>Render</td><td>1000</td><td>576,250.8 μs</td><td>11,258.63 μs</td><td>11,561.78 μs</td><td>149000.0000</td><td>31000.0000</td><td>4000.0000</td><td>1192.54 MB</td> | ||
| </tr></tbody></table> | ||
| </body> | ||
| </html> |
This file contains hidden or 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,25 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="BenchmarkDotNet" Version="0.15.6" /> | ||
| <PackageReference Include="BenchmarkDotNet.Annotations" Version="0.15.7" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Markdown\Markdown.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Update="InputData"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or 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,56 @@ | ||
| # Introduction to Markdown | ||
|
|
||
| Markdown is a lightweight markup language __created__ by John Gruber, with contributions from Aaron Swartz. It’s designed to be easy to read and write, using plain text conventions that translate to valid HTML. | ||
|
|
||
| Markdown allows you to write __bold__ and _italic_ text, create # headings, lists, links, and more — all while keeping the text legible in a raw form. | ||
|
|
||
| --- | ||
|
|
||
| ## Basic Formatting | ||
|
|
||
| Here is an example of __bold text__ and _italic text_ in Markdown. Double underscores surround bold text, while single underscores can be used for italics. Like this: | ||
|
|
||
| __This is bold__, _this is italic_, and __this is __bold with some inner _italic_ text__ too__. | ||
|
|
||
| --- | ||
|
|
||
| ## Combining Tags | ||
|
|
||
| You can combine __bold__ and _italic_ like this: ___bold italic___ text. | ||
|
|
||
| # Headers | ||
|
|
||
| Markdown supports headers starting with `#`: | ||
|
|
||
| # Heading level 1 | ||
|
|
||
| ## Heading level 2 | ||
|
|
||
| ### Heading level 3 | ||
|
|
||
| #### Heading level 4 | ||
|
|
||
| --- | ||
|
|
||
| ## Paragraphs and line breaks | ||
|
|
||
| Markdown treats one or more empty lines as paragraph breaks. | ||
|
|
||
| Use two spaces at the end of a line for a line break. | ||
| Example here with a break. | ||
|
|
||
| ___ | ||
|
|
||
| ## Lists | ||
|
|
||
| - __Bold item__ | ||
| - _Italic item_ | ||
| - Combined __bold and _italic_ item__ | ||
|
|
||
| 1. First numbered item | ||
| 2. Second item with _italic_ | ||
| 3. Third item with __bold__ | ||
|
|
||
|
|
||
| [Name Link](https://www.example.com \"Tooltip\") | ||
| --- |
This file contains hidden or 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,31 @@ | ||
| using System.Text; | ||
| using BenchmarkDotNet.Attributes; | ||
| using Markdown; | ||
|
|
||
| namespace BenchmarkMarkdown; | ||
|
|
||
| [MemoryDiagnoser] | ||
| public class MarkdownParserBenchmark | ||
| { | ||
| private IParser parser; | ||
| private string fileContent; | ||
|
|
||
| [Params(1, 10, 100, 1000)] public int TextSizeMultiplier { get; set; } | ||
|
|
||
| [GlobalSetup] | ||
| public void Setup() | ||
| { | ||
| parser = new MarkdownParser(); | ||
|
|
||
| var baseDir = AppContext.BaseDirectory; | ||
| var filePath = Path.Combine(baseDir, "InputData"); | ||
| var baseFileContent = File.ReadAllText(filePath, Encoding.UTF8); | ||
| fileContent = string.Concat(Enumerable.Repeat(baseFileContent, TextSizeMultiplier)); | ||
| } | ||
|
|
||
| [Benchmark] | ||
| public void Parse() | ||
| { | ||
| parser.Parse(fileContent); | ||
| } | ||
| } |
This file contains hidden or 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,31 @@ | ||
| using System.Text; | ||
| using BenchmarkDotNet.Attributes; | ||
| using Markdown; | ||
|
|
||
| namespace BenchmarkMarkdown; | ||
|
|
||
| [MemoryDiagnoser] | ||
| public class MdBenchmark | ||
| { | ||
| private Md md; | ||
| private string fileContent; | ||
|
|
||
| [Params(1, 10, 100, 1000)] public int TextSizeMultiplier { get; set; } | ||
|
|
||
| [GlobalSetup] | ||
| public void Setup() | ||
| { | ||
| md = new Md(); | ||
|
|
||
| var baseDir = AppContext.BaseDirectory; | ||
| var filePath = Path.Combine(baseDir, "InputData"); | ||
| var baseFileContent = File.ReadAllText(filePath, Encoding.UTF8); | ||
| fileContent = string.Concat(Enumerable.Repeat(baseFileContent, TextSizeMultiplier)); | ||
| } | ||
|
|
||
| [Benchmark] | ||
| public string Render() | ||
| { | ||
| return md.Render(fileContent); | ||
| } | ||
| } |
This file contains hidden or 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,5 @@ | ||
| using BenchmarkDotNet.Running; | ||
| using BenchmarkMarkdown; | ||
|
|
||
| BenchmarkRunner.Run<MarkdownParserBenchmark>(); | ||
| BenchmarkRunner.Run<MdBenchmark>(); |
This file contains hidden or 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,15 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="FluentAssertions" Version="8.8.0" /> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" /> | ||
| <PackageReference Include="NUnit" Version="4.4.0" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or 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,14 @@ | ||
| namespace Markdown; | ||
|
|
||
| public class Md | ||
| { | ||
| private readonly IParser parser = new MarkdownParser(); | ||
| private readonly IRenderer renderer = new HtmlRenderer(); | ||
|
|
||
| public string Render(string markdownText) | ||
| { | ||
| var tokens = parser.Parse(markdownText); | ||
| var result = renderer.Render(tokens, markdownText); | ||
| return result; | ||
| } | ||
| } |
This file contains hidden or 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,8 @@ | ||
| namespace Markdown; | ||
|
|
||
| public class OpenToken(MarkdownTag openTag, int textStartPosition) | ||
| { | ||
| public MarkdownTag OpenTag = openTag; | ||
| public int TextStartPosition = textStartPosition; | ||
| public readonly List<Token> NestedTokens = []; | ||
| } |
This file contains hidden or 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,6 @@ | ||
| namespace Markdown; | ||
|
|
||
| public interface IParser | ||
| { | ||
| public IEnumerable<Token> Parse(string text); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ещё для ознакомления.
Сейчас у тебя структура файлов в проекте - Layer to folder. То есть есть разные слои приложения. По этим слоям мы раскладываем файлы.
Есть ещё один вариант - Feature to folder. Здесь файлы группируются по идейному смыслу, а не по слою. В твоём случае может быть что-то такое
Как по мне Feature to folder выглядит более выигрышным вариантом, тк в большинстве случаев ты работаешь именно с фичей, а не слоем. То есть нужно добавить/измнеить логику Markdown - ты открыл папку Markdown и работаешь только с ней. Конечно сейчас ещё может понадобиться потрогать HtmlRenderer, но в реальных ситуациях это редкость.
В
Layer to folderу тебя может быть открыто большое кол-во верхнеуровневых папок из-за чего может быть тяжело ориентироваться.Я не призываю это исправлять. Просто говорю как можно поступить ещё.