Skip to content

Commit

Permalink
rerun Slazy<T> benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Aug 1, 2021
1 parent 5910151 commit add7300
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 57 deletions.
57 changes: 30 additions & 27 deletions Tools/Towel_Benchmarking/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public static void Main(string[] args)
/// <param name="updateDocumentation">Whether or not to update the docfx documentation.</param>
/// <param name="refreshToc">Whether or not to refresh "toc.yml".</param>
/// <param name="tocPath">The path to the docfx documentation file.</param>
/// <param name="singleBenchmark">Allows you to run a single benchmark at a time.</param>
/// <example>dotnet run --configuration Release run --updateDocumentation True --refreshToc True</example>
[Command]
public static void run(
bool updateDocumentation = false,
bool refreshToc = false,
string? tocPath = null)
string? tocPath = null,
string? singleBenchmark = null)
{
string thisPath = Path.GetDirectoryName(sourcefilepath())!;
if (refreshToc)
Expand All @@ -59,9 +61,7 @@ public static void run(
string[] lines =
{
"- name: Introduction",
" href: intro.md",
"- name: Benchmarks",
" href: benchmarks.md",
" href: index.md",
};
File.WriteAllLines(tocPath, lines);
}
Expand All @@ -82,36 +82,39 @@ public static void run(
}
foreach (Type type in Benchmarks)
{
StringBuilder stringBuilder = new();
string output = RunBenchmarkAndGetMarkdownOutput(type);
stringBuilder.AppendLine($"# {type.GetTag(Name).Value ?? type.Name}");
stringBuilder.AppendLine();
stringBuilder.AppendLine(@"<a href=""https://github.com/ZacharyPatten/Towel"" alt=""Github Repository""><img alt=""github repo"" src=""https://img.shields.io/badge/github-repo-black?logo=github&amp;style=flat"" title=""Go To Github Repo"" alt=""Github Repository""></a>");
stringBuilder.AppendLine();
stringBuilder.AppendLine("The source code for all benchmarks are in [Tools/Towel.Benchmarking](https://github.com/ZacharyPatten/Towel/tree/main/Tools/Towel_Benchmarking).");
stringBuilder.AppendLine();
stringBuilder.AppendLine(output);
if (updateDocumentation)
if (type.Name == singleBenchmark)
{
string documentationPath = Path.Combine(thisPath, "..", "docfx_project", "benchmarks", type.GetTag(OutputFile).Value + ".md");
if (Directory.Exists(Path.GetDirectoryName(documentationPath)))
StringBuilder stringBuilder = new();
string output = RunBenchmarkAndGetMarkdownOutput(type);
stringBuilder.AppendLine($"# {type.GetTag(Name).Value ?? type.Name}");
stringBuilder.AppendLine();
stringBuilder.AppendLine(@"<a href=""https://github.com/ZacharyPatten/Towel"" alt=""Github Repository""><img alt=""github repo"" src=""https://img.shields.io/badge/github-repo-black?logo=github&amp;style=flat"" title=""Go To Github Repo"" alt=""Github Repository""></a>");
stringBuilder.AppendLine();
stringBuilder.AppendLine("The source code for all benchmarks are in [Tools/Towel.Benchmarking](https://github.com/ZacharyPatten/Towel/tree/main/Tools/Towel_Benchmarking).");
stringBuilder.AppendLine();
stringBuilder.AppendLine(output);
if (updateDocumentation)
{
File.WriteAllText(documentationPath, stringBuilder.ToString());
string documentationPath = Path.Combine(thisPath, "..", "docfx_project", "benchmarks", type.GetTag(OutputFile).Value + ".md");
if (Directory.Exists(Path.GetDirectoryName(documentationPath)))
{
File.WriteAllText(documentationPath, stringBuilder.ToString());
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine("-----------------------------------");
Console.Error.WriteLine("ERROR: documentation path not found");
Console.Error.WriteLine($" documentation path: {documentationPath}");
Console.Error.WriteLine("-----------------------------------");
Console.ResetColor();
}
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine("-----------------------------------");
Console.Error.WriteLine("ERROR: documentation path not found");
Console.Error.WriteLine($" documentation path: {documentationPath}");
Console.Error.WriteLine("-----------------------------------");
Console.ResetColor();
Console.WriteLine(stringBuilder.ToString());
}
}
else
{
Console.WriteLine(stringBuilder.ToString());
}
if (refreshToc)
{
string[] lines =
Expand Down
26 changes: 13 additions & 13 deletions Tools/docfx_project/benchmarks/SlazyCachingBenchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ Intel Core i7-4790K CPU 4.00GHz (Haswell), 1 CPU, 8 logical and 4 physical cores


```
| Method | N | Mean | Error | StdDev | Median | Ratio | RatioSD |
|------- |----- |----------:|----------:|----------:|----------:|------:|--------:|
| **Lazy** | **1** | **28.52 ns** | **0.462 ns** | **0.409 ns** | **28.44 ns** | **1.00** | **0.00** |
| SLazy | 1 | 22.27 ns | 0.104 ns | 0.092 ns | 22.25 ns | 0.78 | 0.01 |
| | | | | | | | |
| **Lazy** | **10** | **33.64 ns** | **0.578 ns** | **0.568 ns** | **33.67 ns** | **1.00** | **0.00** |
| SLazy | 10 | 27.18 ns | 0.533 ns | 1.000 ns | 26.67 ns | 0.83 | 0.03 |
| | | | | | | | |
| **Lazy** | **100** | **86.80 ns** | **0.590 ns** | **0.492 ns** | **86.75 ns** | **1.00** | **0.00** |
| SLazy | 100 | 76.55 ns | 1.124 ns | 0.996 ns | 76.62 ns | 0.88 | 0.01 |
| | | | | | | | |
| **Lazy** | **1000** | **531.80 ns** | **10.674 ns** | **22.748 ns** | **521.80 ns** | **1.00** | **0.00** |
| SLazy | 1000 | 502.72 ns | 8.423 ns | 7.879 ns | 500.57 ns | 0.90 | 0.04 |
| Method | N | Mean | Error | StdDev | Ratio | RatioSD |
|------- |----- |----------:|----------:|----------:|------:|--------:|
| **Lazy** | **1** | **31.01 ns** | **0.449 ns** | **0.398 ns** | **1.00** | **0.00** |
| SLazy | 1 | 26.70 ns | 0.252 ns | 0.236 ns | 0.86 | 0.01 |
| | | | | | | |
| **Lazy** | **10** | **36.83 ns** | **0.474 ns** | **0.420 ns** | **1.00** | **0.00** |
| SLazy | 10 | 29.16 ns | 0.404 ns | 0.378 ns | 0.79 | 0.01 |
| | | | | | | |
| **Lazy** | **100** | **91.55 ns** | **1.279 ns** | **1.134 ns** | **1.00** | **0.00** |
| SLazy | 100 | 81.45 ns | 1.136 ns | 1.007 ns | 0.89 | 0.02 |
| | | | | | | |
| **Lazy** | **1000** | **552.06 ns** | **11.075 ns** | **15.159 ns** | **1.00** | **0.00** |
| SLazy | 1000 | 518.34 ns | 3.411 ns | 3.024 ns | 0.93 | 0.03 |

34 changes: 17 additions & 17 deletions Tools/docfx_project/benchmarks/SlazyInitializationBenchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ BenchmarkDotNet=v0.13.0, OS=Windows 10.0.19042.1110 (20H2/October2020Update)
Intel Core i7-4790K CPU 4.00GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.100-preview.6.21355.2
[Host] : .NET 5.0.8 (5.0.821.31504), X64 RyuJIT
Job-HBXSTX : .NET 5.0.8 (5.0.821.31504), X64 RyuJIT
Job-VGOPQH : .NET 5.0.8 (5.0.821.31504), X64 RyuJIT

InvocationCount=1 UnrollFactor=1

```
| Method | N | Mean | Error | StdDev | Median | Ratio | RatioSD |
|------- |------ |-------------:|------------:|-------------:|-------------:|------:|--------:|
| **Lazy** | **1** | **453.5 ns** | **19.06 ns** | **55.90 ns** | **500.0 ns** | **1.00** | **0.00** |
| SLazy | 1 | 290.7 ns | 10.05 ns | 29.16 ns | 300.0 ns | 0.65 | 0.11 |
| | | | | | | | |
| **Lazy** | **10** | **595.8 ns** | **15.70 ns** | **20.41 ns** | **600.0 ns** | **1.00** | **0.00** |
| SLazy | 10 | 457.7 ns | 17.82 ns | 51.71 ns | 500.0 ns | 0.78 | 0.11 |
| | | | | | | | |
| **Lazy** | **100** | **2,895.5 ns** | **58.81 ns** | **72.22 ns** | **2,900.0 ns** | **1.00** | **0.00** |
| SLazy | 100 | 2,270.6 ns | 45.74 ns | 46.97 ns | 2,300.0 ns | 0.78 | 0.03 |
| | | | | | | | |
| **Lazy** | **1000** | **24,678.6 ns** | **283.93 ns** | **251.70 ns** | **24,800.0 ns** | **1.00** | **0.00** |
| SLazy | 1000 | 19,550.0 ns | 0.00 ns | 0.00 ns | 19,550.0 ns | 0.79 | 0.01 |
| | | | | | | | |
| **Lazy** | **10000** | **200,038.9 ns** | **7,143.13 ns** | **19,912.18 ns** | **191,300.0 ns** | **1.00** | **0.00** |
| SLazy | 10000 | 193,445.5 ns | 2,806.10 ns | 3,446.15 ns | 192,350.0 ns | 0.87 | 0.09 |
| Method | N | Mean | Error | StdDev | Median | Ratio | RatioSD |
|------- |------ |-------------:|-------------:|-------------:|-------------:|------:|--------:|
| **Lazy** | **1** | **500.0 ns** | **0.00 ns** | **0.00 ns** | **500.0 ns** | **1.00** | **0.00** |
| SLazy | 1 | 341.8 ns | 23.05 ns | 67.23 ns | 300.0 ns | 0.63 | 0.12 |
| | | | | | | | |
| **Lazy** | **10** | **683.8 ns** | **15.48 ns** | **37.10 ns** | **700.0 ns** | **1.00** | **0.00** |
| SLazy | 10 | 433.3 ns | 13.44 ns | 37.48 ns | 450.0 ns | 0.63 | 0.07 |
| | | | | | | | |
| **Lazy** | **100** | **2,941.2 ns** | **60.21 ns** | **61.83 ns** | **2,900.0 ns** | **1.00** | **0.00** |
| SLazy | 100 | 2,426.1 ns | 48.96 ns | 61.92 ns | 2,400.0 ns | 0.82 | 0.03 |
| | | | | | | | |
| **Lazy** | **1000** | **25,069.2 ns** | **310.69 ns** | **259.44 ns** | **25,000.0 ns** | **1.00** | **0.00** |
| SLazy | 1000 | 20,933.3 ns | 106.93 ns | 83.48 ns | 20,950.0 ns | 0.83 | 0.01 |
| | | | | | | | |
| **Lazy** | **10000** | **234,102.1 ns** | **14,330.77 ns** | **41,117.66 ns** | **236,800.0 ns** | **1.00** | **0.00** |
| SLazy | 10000 | 201,431.0 ns | 6,087.77 ns | 16,665.16 ns | 203,300.0 ns | 0.87 | 0.14 |

0 comments on commit add7300

Please sign in to comment.