From 1ac8a855c82958a1698bcd51022389b29ec7208f Mon Sep 17 00:00:00 2001 From: Paul Westcott Date: Sun, 8 Sep 2019 19:38:52 +1000 Subject: [PATCH 1/3] benchmarking with cistern 0.0.2 --- .../Cistern.cs | 174 ++++++++++++++++++ .../LinqOptimizer.Benchmarks.CSharp.csproj | 17 +- .../Program.cs | 50 ++--- 3 files changed, 212 insertions(+), 29 deletions(-) create mode 100644 benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs diff --git a/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs b/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs new file mode 100644 index 0000000..0e8f552 --- /dev/null +++ b/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs @@ -0,0 +1,174 @@ +using BenchmarkDotNet.Attributes; +using Nessos.LinqOptimizer.CSharp; +using Cistern.Linq; + +namespace LinqOptimizer.Benchmarks.CSharp +{ + public partial class SequentialBenchmarks + { + public partial class SumBechmarks : BenchmarkBase + { + /* + | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |-------------- |-------- |----------------:|---------------:|---------------:|---------:|--------:|-------:|------:|------:|----------:| + | 'Sum Cistern' | 0 | 27.28 ns | 0.1769 ns | 0.1568 ns | 1.93 | 0.03 | 0.0102 | - | - | 32 B | + | 'Sum Linq' | 0 | 14.10 ns | 0.1832 ns | 0.1624 ns | 1.00 | 0.00 | - | - | - | - | + | 'Sum Opt' | 0 | 46,790.91 ns | 497.3814 ns | 465.2509 ns | 3,314.35 | 60.80 | 5.1880 | - | - | 16508 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 10 | 42.05 ns | 0.2423 ns | 0.2266 ns | 0.55 | 0.01 | 0.0101 | - | - | 32 B | + | 'Sum Linq' | 10 | 76.30 ns | 0.7380 ns | 0.6903 ns | 1.00 | 0.00 | 0.0101 | - | - | 32 B | + | 'Sum Opt' | 10 | 47,269.71 ns | 339.5650 ns | 317.6293 ns | 619.60 | 7.57 | 5.1880 | - | - | 16508 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 100 | 166.20 ns | 1.2624 ns | 1.1809 ns | 0.28 | 0.00 | 0.0100 | - | - | 32 B | + | 'Sum Linq' | 100 | 604.18 ns | 3.6638 ns | 3.4271 ns | 1.00 | 0.00 | 0.0095 | - | - | 32 B | + | 'Sum Opt' | 100 | 47,431.70 ns | 302.0929 ns | 282.5779 ns | 78.51 | 0.62 | 5.1880 | - | - | 16508 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 10000 | 13,764.76 ns | 86.0308 ns | 80.4733 ns | 0.25 | 0.00 | - | - | - | 32 B | + | 'Sum Linq' | 10000 | 55,296.67 ns | 373.1092 ns | 330.7516 ns | 1.00 | 0.00 | - | - | - | 32 B | + | 'Sum Opt' | 10000 | 62,573.14 ns | 653.2285 ns | 611.0303 ns | 1.13 | 0.01 | 5.1270 | - | - | 16508 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 1000000 | 1,389,519.47 ns | 7,837.1676 ns | 7,330.8914 ns | 0.25 | 0.00 | - | - | - | 32 B | + | 'Sum Linq' | 1000000 | 5,507,463.90 ns | 20,544.6872 ns | 18,212.3301 ns | 1.00 | 0.00 | - | - | - | 32 B | + | 'Sum Opt' | 1000000 | 1,437,876.07 ns | 11,039.3320 ns | 10,326.1980 ns | 0.26 | 0.00 | 3.9063 | - | - | 16509 B | + */ + [Benchmark(Description = "Sum Cistern")] + public double SumCistern() + { + return values.Sum(); + } + } + + /* + | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |------------------------- |-------- |----------------:|---------------:|---------------:|---------:|--------:|-------:|------:|------:|----------:| + | 'Sum of Squares Cistern' | 0 | 32.80 ns | 0.4647 ns | 0.4120 ns | 0.79 | 0.02 | 0.0101 | - | - | 32 B | + | 'Sum of Squares Linq' | 0 | 41.33 ns | 0.8723 ns | 1.0046 ns | 1.00 | 0.00 | - | - | - | - | + | 'Sum of Squares Opt' | 0 | 60,655.93 ns | 1,004.6357 ns | 939.7369 ns | 1,462.69 | 44.13 | 5.9204 | - | - | 18733 B | + | | | | | | | | | | | | + | 'Sum of Squares Cistern' | 10 | 109.62 ns | 0.7830 ns | 0.7324 ns | 0.64 | 0.01 | 0.0483 | - | - | 152 B | + | 'Sum of Squares Linq' | 10 | 172.53 ns | 1.4346 ns | 1.3419 ns | 1.00 | 0.00 | 0.0150 | - | - | 48 B | + | 'Sum of Squares Opt' | 10 | 60,081.55 ns | 610.3621 ns | 570.9330 ns | 348.26 | 4.22 | 5.9204 | - | - | 18733 B | + | | | | | | | | | | | | + | 'Sum of Squares Cistern' | 100 | 308.26 ns | 2.3056 ns | 2.1567 ns | 0.32 | 0.00 | 0.0482 | - | - | 152 B | + | 'Sum of Squares Linq' | 100 | 952.33 ns | 10.2225 ns | 9.5621 ns | 1.00 | 0.00 | 0.0143 | - | - | 48 B | + | 'Sum of Squares Opt' | 100 | 60,050.67 ns | 361.5115 ns | 338.1580 ns | 63.06 | 0.68 | 5.9204 | - | - | 18733 B | + | | | | | | | | | | | | + | 'Sum of Squares Cistern' | 10000 | 20,931.97 ns | 108.3494 ns | 101.3501 ns | 0.24 | 0.00 | 0.0305 | - | - | 152 B | + | 'Sum of Squares Linq' | 10000 | 88,243.58 ns | 793.2973 ns | 742.0508 ns | 1.00 | 0.00 | - | - | - | 48 B | + | 'Sum of Squares Opt' | 10000 | 76,492.69 ns | 1,187.3593 ns | 1,110.6567 ns | 0.87 | 0.01 | 5.8594 | - | - | 18733 B | + | | | | | | | | | | | | + | 'Sum of Squares Cistern' | 1000000 | 2,078,028.80 ns | 16,876.6655 ns | 15,786.4434 ns | 0.24 | 0.00 | - | - | - | 152 B | + | 'Sum of Squares Linq' | 1000000 | 8,754,710.42 ns | 66,414.0752 ns | 62,123.7671 ns | 1.00 | 0.00 | - | - | - | 48 B | + | 'Sum of Squares Opt' | 1000000 | 1,457,266.62 ns | 12,679.7592 ns | 11,240.2762 ns | 0.17 | 0.00 | 5.8594 | - | - | 18735 B | + */ + public partial class SumOfSquaresBechmarks : BenchmarkBase + { + [Benchmark(Description = "Sum of Squares Cistern")] + public double SumSqCistern() + { + return values.Select(x => x * x).Sum(); + } + } + + /* + | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |-------------------- |-------- |-----------------:|----------------:|----------------:|---------:|--------:|----------:|------:|------:|----------:| + | 'Cartesian Cistern' | 0 | 107.11 ns | 0.3919 ns | 0.3665 ns | 1.51 | 0.01 | 0.0685 | - | - | 216 B | + | 'Cartesian Linq' | 0 | 71.01 ns | 0.6543 ns | 0.5800 ns | 1.00 | 0.00 | 0.0533 | - | - | 168 B | + | 'Cartesian Opt' | 0 | 109,861.61 ns | 481.1207 ns | 450.0406 ns | 1,547.06 | 12.58 | 11.1084 | - | - | 35050 B | + | | | | | | | | | | | | + | 'Cartesian Cistern' | 10 | 199.06 ns | 1.2596 ns | 1.1166 ns | 0.71 | 0.01 | 0.0913 | - | - | 288 B | + | 'Cartesian Linq' | 10 | 282.24 ns | 2.9057 ns | 2.7180 ns | 1.00 | 0.00 | 0.0734 | - | - | 232 B | + | 'Cartesian Opt' | 10 | 109,093.80 ns | 652.4443 ns | 610.2968 ns | 386.55 | 3.88 | 11.1084 | - | - | 35050 B | + | | | | | | | | | | | | + | 'Cartesian Cistern' | 100 | 1,036.78 ns | 6.9351 ns | 6.4871 ns | 0.30 | 0.00 | 0.0896 | - | - | 288 B | + | 'Cartesian Linq' | 100 | 3,491.20 ns | 29.3154 ns | 27.4217 ns | 1.00 | 0.00 | 0.1640 | - | - | 520 B | + | 'Cartesian Opt' | 100 | 109,082.81 ns | 813.5949 ns | 761.0372 ns | 31.25 | 0.25 | 11.1084 | - | - | 35050 B | + | | | | | | | | | | | | + | 'Cartesian Cistern' | 10000 | 86,116.90 ns | 686.6200 ns | 642.2648 ns | 0.26 | 0.00 | - | - | - | 288 B | + | 'Cartesian Linq' | 10000 | 337,411.42 ns | 3,040.0049 ns | 2,694.8852 ns | 1.00 | 0.00 | 9.7656 | - | - | 32200 B | + | 'Cartesian Opt' | 10000 | 138,558.95 ns | 1,154.6305 ns | 1,023.5498 ns | 0.41 | 0.00 | 10.9863 | - | - | 35050 B | + | | | | | | | | | | | | + | 'Cartesian Cistern' | 1000000 | 8,606,452.60 ns | 97,523.0158 ns | 91,223.0895 ns | 0.25 | 0.00 | - | - | - | 288 B | + | 'Cartesian Linq' | 1000000 | 33,758,322.92 ns | 373,052.7235 ns | 348,953.7490 ns | 1.00 | 0.00 | 1000.0000 | - | - | 3200200 B | + | 'Cartesian Opt' | 1000000 | 2,878,193.54 ns | 19,063.2906 ns | 17,831.8138 ns | 0.09 | 0.00 | 7.8125 | - | - | 35052 B |*/ + public partial class CartesianBenchmarks : BenchmarkBase + { + [Benchmark(Description = "Cartesian Cistern")] + public double CartCistern() + { + return (from x in dim1 + from y in dim2 + select x * y).Sum(); + } + } + + /* + | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |------------------- |-------- |-----------------:|------------------:|------------------:|---------:|--------:|-----------:|----------:|----------:|------------:| + | 'Group By Cistern' | 0 | 393.8 ns | 1.753 ns | 1.554 ns | 1.48 | 0.01 | 0.2208 | - | - | 696 B | + | 'Group By Linq' | 0 | 265.7 ns | 2.048 ns | 1.815 ns | 1.00 | 0.00 | 0.1168 | - | - | 368 B | + | 'Group By Opt' | 0 | 399,551.1 ns | 2,872.557 ns | 2,686.992 ns | 1,503.77 | 18.07 | 39.0625 | - | - | 124235 B | + | | | | | | | | | | | | + | 'Group By Cistern' | 10 | 3,142.9 ns | 25.285 ns | 23.652 ns | 1.24 | 0.02 | 0.8087 | - | - | 2552 B | + | 'Group By Linq' | 10 | 2,535.5 ns | 22.280 ns | 20.841 ns | 1.00 | 0.00 | 0.6523 | - | - | 2056 B | + | 'Group By Opt' | 10 | 405,738.9 ns | 2,854.742 ns | 2,670.328 ns | 160.03 | 1.71 | 46.3867 | - | - | 147332 B | + | | | | | | | | | | | | + | 'Group By Cistern' | 100 | 25,933.3 ns | 133.420 ns | 124.801 ns | 1.14 | 0.01 | 4.7607 | - | - | 15056 B | + | 'Group By Linq' | 100 | 22,751.6 ns | 157.226 ns | 147.069 ns | 1.00 | 0.00 | 4.4861 | - | - | 14192 B | + | 'Group By Opt' | 100 | 445,883.5 ns | 4,056.576 ns | 3,794.524 ns | 19.60 | 0.23 | 53.2227 | - | - | 168420 B | + | | | | | | | | | | | | + | 'Group By Cistern' | 10000 | 5,212,502.0 ns | 26,990.373 ns | 25,246.812 ns | 0.96 | 0.01 | 242.1875 | 148.4375 | 78.1250 | 1497438 B | + | 'Group By Linq' | 10000 | 5,411,742.6 ns | 26,162.135 ns | 24,472.078 ns | 1.00 | 0.00 | 226.5625 | 109.3750 | 46.8750 | 1405855 B | + | 'Group By Opt' | 10000 | 6,185,879.8 ns | 38,216.056 ns | 35,747.323 ns | 1.14 | 0.01 | 398.4375 | 296.8750 | 296.8750 | 3016919 B | + | | | | | | | | | | | | + | 'Group By Cistern' | 1000000 | 721,762,426.7 ns | 11,219,209.587 ns | 10,494,455.608 ns | 0.93 | 0.01 | 12000.0000 | 6000.0000 | 2000.0000 | 109197016 B | + | 'Group By Linq' | 1000000 | 777,703,673.3 ns | 7,380,273.468 ns | 6,903,512.381 ns | 1.00 | 0.00 | 13000.0000 | 6000.0000 | 2000.0000 | 104646152 B | + | 'Group By Opt' | 1000000 | 780,702,233.3 ns | 12,137,050.645 ns | 11,353,004.704 ns | 1.00 | 0.01 | 16000.0000 | 6000.0000 | 2000.0000 | 169265304 B | + */ + public partial class GroupByBenchmarks : BenchmarkBase + { + [Benchmark(Description = "Group By Cistern")] + public int[] GroupCistern() + { + return values + .GroupBy(x => (int)x / 100) + .OrderBy(x => x.Key) + .Select(k => k.Count()) + .ToArray(); + } + } + + /* + | Method | max | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |------------------------------ |----- |-------------------:|------------------:|------------------:|---------:|--------:|-------------:|------:|------:|-------------:| + | 'Pythagorean Triples Cistern' | 0 | 582.0 ns | 3.611 ns | 3.378 ns | 1.77 | 0.02 | 0.2508 | - | - | 792 B | + | 'Pythagorean Triples Linq' | 0 | 328.5 ns | 3.229 ns | 2.863 ns | 1.00 | 0.00 | 0.1574 | - | - | 496 B | + | 'Pythagorean Triples Opt' | 0 | 354,655.9 ns | 2,922.388 ns | 2,733.604 ns | 1,079.29 | 11.53 | 30.7617 | - | - | 98062 B | + | | | | | | | | | | | | + | 'Pythagorean Triples Cistern' | 10 | 8,634.1 ns | 71.339 ns | 66.730 ns | 0.81 | 0.01 | 3.5706 | - | - | 11280 B | + | 'Pythagorean Triples Linq' | 10 | 10,660.5 ns | 79.319 ns | 70.314 ns | 1.00 | 0.00 | 3.6316 | - | - | 11456 B | + | 'Pythagorean Triples Opt' | 10 | 352,958.6 ns | 1,962.591 ns | 1,739.786 ns | 33.11 | 0.29 | 30.7617 | - | - | 98070 B | + | | | | | | | | | | | | + | 'Pythagorean Triples Cistern' | 100 | 3,170,986.0 ns | 23,760.764 ns | 22,225.833 ns | 0.65 | 0.01 | 1835.9375 | - | - | 5781240 B | + | 'Pythagorean Triples Linq' | 100 | 4,871,139.9 ns | 28,270.715 ns | 26,444.445 ns | 1.00 | 0.00 | 1843.7500 | - | - | 5822096 B | + | 'Pythagorean Triples Opt' | 100 | 571,383.5 ns | 3,913.331 ns | 3,660.532 ns | 0.12 | 0.00 | 30.2734 | - | - | 98070 B | + | | | | | | | | | | | | + | 'Pythagorean Triples Cistern' | 1000 | 2,781,007,992.9 ns | 9,857,092.030 ns | 8,738,055.338 ns | 0.63 | 0.00 | 1709000.0000 | - | - | 5377404840 B | + | 'Pythagorean Triples Linq' | 1000 | 4,384,790,307.1 ns | 16,578,918.412 ns | 14,696,779.342 ns | 1.00 | 0.00 | 1710000.0000 | - | - | 5381416496 B | + | 'Pythagorean Triples Opt' | 1000 | 176,375,866.7 ns | 2,141,939.770 ns | 2,003,571.790 ns | 0.04 | 0.00 | - | - | - | 100344 B | + */ + public partial class PythagoreanTriplesBenchmarks + { + [Benchmark(Description = "Pythagorean Triples Cistern")] + public int PythagoreanTriplesCistern() + { + return (from a in Enumerable.Range(1, max + 1) + from b in Enumerable.Range(a, max + 1 - a) + from c in Enumerable.Range(b, max + 1 - b) + where a * a + b * b == c * c + select true).Count(); + } + } + } +} diff --git a/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj b/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj index 62d1670..8d50ec2 100644 --- a/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj +++ b/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj @@ -1,16 +1,17 @@ - - + + - netcoreapp2.2;net461 - AnyCPU - true - true - + Exe + netcoreapp2.2 + + + - \ No newline at end of file + + diff --git a/benchmarks/LinqOptimizer.Benchmarks.CSharp/Program.cs b/benchmarks/LinqOptimizer.Benchmarks.CSharp/Program.cs index ef74c80..23ede38 100644 --- a/benchmarks/LinqOptimizer.Benchmarks.CSharp/Program.cs +++ b/benchmarks/LinqOptimizer.Benchmarks.CSharp/Program.cs @@ -15,11 +15,15 @@ class Program { static void Main(string[] args) { +#if fales typeof(SequentialBenchmarks) .GetNestedTypes() .Concat(typeof(ParallelBenchmarks).GetNestedTypes()) .ToList() .ForEach(type => BenchmarkRunner.Run(type, new CustomConfig())); +#else + BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); +#endif } } @@ -46,15 +50,20 @@ public class BenchmarkBase protected double[] values; [GlobalSetup] - public virtual void SetUp() + public void SetUp() { values = Enumerable.Range(1, Count).Select(x => rnd.NextDouble()).ToArray(); + + AdditionalSetUp(); } + + virtual protected void AdditionalSetUp() { } } - public class SequentialBenchmarks + public partial class SequentialBenchmarks { - public class SumBechmarks : BenchmarkBase + [CoreJob, MemoryDiagnoser] + public partial class SumBechmarks : BenchmarkBase { [Benchmark(Description = "Sum Linq", Baseline = true)] public double SumLinq() @@ -69,7 +78,8 @@ public double SumLinqOpt() } } - public class SumOfSquaresBechmarks : BenchmarkBase + [CoreJob, MemoryDiagnoser] + public partial class SumOfSquaresBechmarks : BenchmarkBase { [Benchmark(Description = "Sum of Squares Linq", Baseline = true)] public double SumSqLinq() @@ -84,15 +94,13 @@ public double SumSqLinqOpt() } } - public class CartesianBenchmarks : BenchmarkBase + [CoreJob, MemoryDiagnoser] + public partial class CartesianBenchmarks : BenchmarkBase { private double[] dim1, dim2; - [GlobalSetup] - public override void SetUp() + protected override void AdditionalSetUp() { - base.SetUp(); - dim1 = values.Take(values.Length / 10).ToArray(); dim2 = values.Take(20).ToArray(); } @@ -114,13 +122,11 @@ from y in dim2 } } - public class GroupByBenchmarks : BenchmarkBase + [CoreJob, MemoryDiagnoser] + public partial class GroupByBenchmarks : BenchmarkBase { - [GlobalSetup] - public override void SetUp() + protected override void AdditionalSetUp() { - base.SetUp(); - values = Enumerable.Range(1, Count).Select(x => 100000000 * rnd.NextDouble() - 50000000).ToArray(); } @@ -147,7 +153,8 @@ public int[] GroupByOpt() } } - public class PythagoreanTriplesBenchmarks + [CoreJob, MemoryDiagnoser] + public partial class PythagoreanTriplesBenchmarks { [Params(0, 10, 100, 1000)] public int max = 1000; @@ -176,6 +183,7 @@ from c in Enumerable.Range(b, max + 1 - b) public class ParallelBenchmarks { + [CoreJob, MemoryDiagnoser] public class ParallelSumBenchmarks : BenchmarkBase { [Benchmark(Description = "Parallel Sum Linq", Baseline = true)] @@ -191,6 +199,7 @@ public double ParallelSumOpt() } } + [CoreJob, MemoryDiagnoser] public class ParallelSumOfSquaresBenchmark : BenchmarkBase { [Benchmark(Description = "Parallel Sum of Squares Linq", Baseline = true)] @@ -206,15 +215,13 @@ public double ParallelSumSqLinqOpt() } } + [CoreJob, MemoryDiagnoser] public class ParallelCartesianBenchmarks : BenchmarkBase { private double[] dim1, dim2; - [GlobalSetup] - public override void SetUp() + protected override void AdditionalSetUp() { - base.SetUp(); - dim1 = values.Take(values.Length / 10).ToArray(); dim2 = values.Take(20).ToArray(); } @@ -236,10 +243,10 @@ from y in dim2 } } + [CoreJob, MemoryDiagnoser] public class ParallelGroupByBenchmarks : BenchmarkBase { - [GlobalSetup] - public override void SetUp() + protected override void AdditionalSetUp() { values = Enumerable.Range(1, Count).Select(x => 100000000 * rnd.NextDouble() - 50000000).ToArray(); } @@ -266,6 +273,7 @@ public int[] ParallelGroupLinqOpt() } } + [CoreJob, MemoryDiagnoser] public class ParallelPythagoreanTriplesBenchmarks { [Params(0, 10, 100, 1000)] From 2c0f988a11091b04358a442889b270cfd54c778f Mon Sep 17 00:00:00 2001 From: Paul Westcott Date: Mon, 9 Sep 2019 17:23:23 +1000 Subject: [PATCH 2/3] Updated Cistern version --- .../Cistern.cs | 70 +++++++++---------- .../LinqOptimizer.Benchmarks.CSharp.csproj | 2 +- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs b/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs index 0e8f552..5fe7588 100644 --- a/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs +++ b/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs @@ -6,31 +6,31 @@ namespace LinqOptimizer.Benchmarks.CSharp { public partial class SequentialBenchmarks { + /* + | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |-------------- |-------- |----------------:|---------------:|---------------:|---------:|--------:|-------:|------:|------:|----------:| + | 'Sum Cistern' | 0 | 27.28 ns | 0.1769 ns | 0.1568 ns | 1.93 | 0.03 | 0.0102 | - | - | 32 B | + | 'Sum Linq' | 0 | 14.10 ns | 0.1832 ns | 0.1624 ns | 1.00 | 0.00 | - | - | - | - | + | 'Sum Opt' | 0 | 46,790.91 ns | 497.3814 ns | 465.2509 ns | 3,314.35 | 60.80 | 5.1880 | - | - | 16508 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 10 | 42.05 ns | 0.2423 ns | 0.2266 ns | 0.55 | 0.01 | 0.0101 | - | - | 32 B | + | 'Sum Linq' | 10 | 76.30 ns | 0.7380 ns | 0.6903 ns | 1.00 | 0.00 | 0.0101 | - | - | 32 B | + | 'Sum Opt' | 10 | 47,269.71 ns | 339.5650 ns | 317.6293 ns | 619.60 | 7.57 | 5.1880 | - | - | 16508 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 100 | 166.20 ns | 1.2624 ns | 1.1809 ns | 0.28 | 0.00 | 0.0100 | - | - | 32 B | + | 'Sum Linq' | 100 | 604.18 ns | 3.6638 ns | 3.4271 ns | 1.00 | 0.00 | 0.0095 | - | - | 32 B | + | 'Sum Opt' | 100 | 47,431.70 ns | 302.0929 ns | 282.5779 ns | 78.51 | 0.62 | 5.1880 | - | - | 16508 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 10000 | 13,764.76 ns | 86.0308 ns | 80.4733 ns | 0.25 | 0.00 | - | - | - | 32 B | + | 'Sum Linq' | 10000 | 55,296.67 ns | 373.1092 ns | 330.7516 ns | 1.00 | 0.00 | - | - | - | 32 B | + | 'Sum Opt' | 10000 | 62,573.14 ns | 653.2285 ns | 611.0303 ns | 1.13 | 0.01 | 5.1270 | - | - | 16508 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 1000000 | 1,389,519.47 ns | 7,837.1676 ns | 7,330.8914 ns | 0.25 | 0.00 | - | - | - | 32 B | + | 'Sum Linq' | 1000000 | 5,507,463.90 ns | 20,544.6872 ns | 18,212.3301 ns | 1.00 | 0.00 | - | - | - | 32 B | + | 'Sum Opt' | 1000000 | 1,437,876.07 ns | 11,039.3320 ns | 10,326.1980 ns | 0.26 | 0.00 | 3.9063 | - | - | 16509 B | + */ public partial class SumBechmarks : BenchmarkBase { - /* - | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | - |-------------- |-------- |----------------:|---------------:|---------------:|---------:|--------:|-------:|------:|------:|----------:| - | 'Sum Cistern' | 0 | 27.28 ns | 0.1769 ns | 0.1568 ns | 1.93 | 0.03 | 0.0102 | - | - | 32 B | - | 'Sum Linq' | 0 | 14.10 ns | 0.1832 ns | 0.1624 ns | 1.00 | 0.00 | - | - | - | - | - | 'Sum Opt' | 0 | 46,790.91 ns | 497.3814 ns | 465.2509 ns | 3,314.35 | 60.80 | 5.1880 | - | - | 16508 B | - | | | | | | | | | | | | - | 'Sum Cistern' | 10 | 42.05 ns | 0.2423 ns | 0.2266 ns | 0.55 | 0.01 | 0.0101 | - | - | 32 B | - | 'Sum Linq' | 10 | 76.30 ns | 0.7380 ns | 0.6903 ns | 1.00 | 0.00 | 0.0101 | - | - | 32 B | - | 'Sum Opt' | 10 | 47,269.71 ns | 339.5650 ns | 317.6293 ns | 619.60 | 7.57 | 5.1880 | - | - | 16508 B | - | | | | | | | | | | | | - | 'Sum Cistern' | 100 | 166.20 ns | 1.2624 ns | 1.1809 ns | 0.28 | 0.00 | 0.0100 | - | - | 32 B | - | 'Sum Linq' | 100 | 604.18 ns | 3.6638 ns | 3.4271 ns | 1.00 | 0.00 | 0.0095 | - | - | 32 B | - | 'Sum Opt' | 100 | 47,431.70 ns | 302.0929 ns | 282.5779 ns | 78.51 | 0.62 | 5.1880 | - | - | 16508 B | - | | | | | | | | | | | | - | 'Sum Cistern' | 10000 | 13,764.76 ns | 86.0308 ns | 80.4733 ns | 0.25 | 0.00 | - | - | - | 32 B | - | 'Sum Linq' | 10000 | 55,296.67 ns | 373.1092 ns | 330.7516 ns | 1.00 | 0.00 | - | - | - | 32 B | - | 'Sum Opt' | 10000 | 62,573.14 ns | 653.2285 ns | 611.0303 ns | 1.13 | 0.01 | 5.1270 | - | - | 16508 B | - | | | | | | | | | | | | - | 'Sum Cistern' | 1000000 | 1,389,519.47 ns | 7,837.1676 ns | 7,330.8914 ns | 0.25 | 0.00 | - | - | - | 32 B | - | 'Sum Linq' | 1000000 | 5,507,463.90 ns | 20,544.6872 ns | 18,212.3301 ns | 1.00 | 0.00 | - | - | - | 32 B | - | 'Sum Opt' | 1000000 | 1,437,876.07 ns | 11,039.3320 ns | 10,326.1980 ns | 0.26 | 0.00 | 3.9063 | - | - | 16509 B | - */ [Benchmark(Description = "Sum Cistern")] public double SumCistern() { @@ -142,21 +142,21 @@ public int[] GroupCistern() /* | Method | max | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | |------------------------------ |----- |-------------------:|------------------:|------------------:|---------:|--------:|-------------:|------:|------:|-------------:| - | 'Pythagorean Triples Cistern' | 0 | 582.0 ns | 3.611 ns | 3.378 ns | 1.77 | 0.02 | 0.2508 | - | - | 792 B | - | 'Pythagorean Triples Linq' | 0 | 328.5 ns | 3.229 ns | 2.863 ns | 1.00 | 0.00 | 0.1574 | - | - | 496 B | - | 'Pythagorean Triples Opt' | 0 | 354,655.9 ns | 2,922.388 ns | 2,733.604 ns | 1,079.29 | 11.53 | 30.7617 | - | - | 98062 B | + | 'Pythagorean Triples Cistern' | 0 | 527.5 ns | 3.755 ns | 3.513 ns | 1.66 | 0.01 | 0.2508 | - | - | 792 B | + | 'Pythagorean Triples Linq' | 0 | 318.4 ns | 2.403 ns | 2.130 ns | 1.00 | 0.00 | 0.1574 | - | - | 496 B | + | 'Pythagorean Triples Opt' | 0 | 348,225.3 ns | 2,112.988 ns | 1,976.491 ns | 1,094.57 | 9.41 | 30.7617 | - | - | 98062 B | | | | | | | | | | | | | - | 'Pythagorean Triples Cistern' | 10 | 8,634.1 ns | 71.339 ns | 66.730 ns | 0.81 | 0.01 | 3.5706 | - | - | 11280 B | - | 'Pythagorean Triples Linq' | 10 | 10,660.5 ns | 79.319 ns | 70.314 ns | 1.00 | 0.00 | 3.6316 | - | - | 11456 B | - | 'Pythagorean Triples Opt' | 10 | 352,958.6 ns | 1,962.591 ns | 1,739.786 ns | 33.11 | 0.29 | 30.7617 | - | - | 98070 B | + | 'Pythagorean Triples Cistern' | 10 | 8,285.1 ns | 84.632 ns | 79.165 ns | 0.80 | 0.01 | 3.5706 | - | - | 11280 B | + | 'Pythagorean Triples Linq' | 10 | 10,385.1 ns | 76.444 ns | 71.506 ns | 1.00 | 0.00 | 3.6316 | - | - | 11456 B | + | 'Pythagorean Triples Opt' | 10 | 351,490.9 ns | 2,800.651 ns | 2,619.731 ns | 33.85 | 0.38 | 30.7617 | - | - | 98070 B | | | | | | | | | | | | | - | 'Pythagorean Triples Cistern' | 100 | 3,170,986.0 ns | 23,760.764 ns | 22,225.833 ns | 0.65 | 0.01 | 1835.9375 | - | - | 5781240 B | - | 'Pythagorean Triples Linq' | 100 | 4,871,139.9 ns | 28,270.715 ns | 26,444.445 ns | 1.00 | 0.00 | 1843.7500 | - | - | 5822096 B | - | 'Pythagorean Triples Opt' | 100 | 571,383.5 ns | 3,913.331 ns | 3,660.532 ns | 0.12 | 0.00 | 30.2734 | - | - | 98070 B | + | 'Pythagorean Triples Cistern' | 100 | 2,964,882.8 ns | 17,915.109 ns | 16,757.804 ns | 0.63 | 0.01 | 1835.9375 | - | - | 5781240 B | + | 'Pythagorean Triples Linq' | 100 | 4,695,351.8 ns | 44,031.952 ns | 41,187.515 ns | 1.00 | 0.00 | 1843.7500 | - | - | 5822096 B | + | 'Pythagorean Triples Opt' | 100 | 568,447.1 ns | 4,059.144 ns | 3,598.326 ns | 0.12 | 0.00 | 30.2734 | - | - | 98070 B | | | | | | | | | | | | | - | 'Pythagorean Triples Cistern' | 1000 | 2,781,007,992.9 ns | 9,857,092.030 ns | 8,738,055.338 ns | 0.63 | 0.00 | 1709000.0000 | - | - | 5377404840 B | - | 'Pythagorean Triples Linq' | 1000 | 4,384,790,307.1 ns | 16,578,918.412 ns | 14,696,779.342 ns | 1.00 | 0.00 | 1710000.0000 | - | - | 5381416496 B | - | 'Pythagorean Triples Opt' | 1000 | 176,375,866.7 ns | 2,141,939.770 ns | 2,003,571.790 ns | 0.04 | 0.00 | - | - | - | 100344 B | + | 'Pythagorean Triples Cistern' | 1000 | 2,469,709,900.0 ns | 8,300,441.640 ns | 7,358,125.312 ns | 0.58 | 0.00 | 1709000.0000 | - | - | 5377404840 B | + | 'Pythagorean Triples Linq' | 1000 | 4,271,984,966.7 ns | 29,321,501.294 ns | 27,427,350.503 ns | 1.00 | 0.00 | 1710000.0000 | - | - | 5381416496 B | + | 'Pythagorean Triples Opt' | 1000 | 173,111,693.3 ns | 1,882,627.953 ns | 1,761,011.356 ns | 0.04 | 0.00 | - | - | - | 100344 B | */ public partial class PythagoreanTriplesBenchmarks { diff --git a/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj b/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj index 8d50ec2..2484c03 100644 --- a/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj +++ b/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj @@ -7,7 +7,7 @@ - + From 3de1988ef746294d21638a2580e9c9d588178c20 Mon Sep 17 00:00:00 2001 From: Paul Westcott Date: Sat, 28 Sep 2019 17:30:26 +1000 Subject: [PATCH 3/3] Updated benchmarks for Cistern 0.1.1 --- .../Cistern.cs | 191 +++++++++--------- .../LinqOptimizer.Benchmarks.CSharp.csproj | 4 +- .../LinqOptimizer.Benchmarks.FSharp.fsproj | 7 +- .../Program.fs | 87 ++++++-- 4 files changed, 175 insertions(+), 114 deletions(-) diff --git a/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs b/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs index 5fe7588..98eec05 100644 --- a/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs +++ b/benchmarks/LinqOptimizer.Benchmarks.CSharp/Cistern.cs @@ -7,27 +7,27 @@ namespace LinqOptimizer.Benchmarks.CSharp public partial class SequentialBenchmarks { /* - | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | - |-------------- |-------- |----------------:|---------------:|---------------:|---------:|--------:|-------:|------:|------:|----------:| - | 'Sum Cistern' | 0 | 27.28 ns | 0.1769 ns | 0.1568 ns | 1.93 | 0.03 | 0.0102 | - | - | 32 B | - | 'Sum Linq' | 0 | 14.10 ns | 0.1832 ns | 0.1624 ns | 1.00 | 0.00 | - | - | - | - | - | 'Sum Opt' | 0 | 46,790.91 ns | 497.3814 ns | 465.2509 ns | 3,314.35 | 60.80 | 5.1880 | - | - | 16508 B | - | | | | | | | | | | | | - | 'Sum Cistern' | 10 | 42.05 ns | 0.2423 ns | 0.2266 ns | 0.55 | 0.01 | 0.0101 | - | - | 32 B | - | 'Sum Linq' | 10 | 76.30 ns | 0.7380 ns | 0.6903 ns | 1.00 | 0.00 | 0.0101 | - | - | 32 B | - | 'Sum Opt' | 10 | 47,269.71 ns | 339.5650 ns | 317.6293 ns | 619.60 | 7.57 | 5.1880 | - | - | 16508 B | - | | | | | | | | | | | | - | 'Sum Cistern' | 100 | 166.20 ns | 1.2624 ns | 1.1809 ns | 0.28 | 0.00 | 0.0100 | - | - | 32 B | - | 'Sum Linq' | 100 | 604.18 ns | 3.6638 ns | 3.4271 ns | 1.00 | 0.00 | 0.0095 | - | - | 32 B | - | 'Sum Opt' | 100 | 47,431.70 ns | 302.0929 ns | 282.5779 ns | 78.51 | 0.62 | 5.1880 | - | - | 16508 B | - | | | | | | | | | | | | - | 'Sum Cistern' | 10000 | 13,764.76 ns | 86.0308 ns | 80.4733 ns | 0.25 | 0.00 | - | - | - | 32 B | - | 'Sum Linq' | 10000 | 55,296.67 ns | 373.1092 ns | 330.7516 ns | 1.00 | 0.00 | - | - | - | 32 B | - | 'Sum Opt' | 10000 | 62,573.14 ns | 653.2285 ns | 611.0303 ns | 1.13 | 0.01 | 5.1270 | - | - | 16508 B | - | | | | | | | | | | | | - | 'Sum Cistern' | 1000000 | 1,389,519.47 ns | 7,837.1676 ns | 7,330.8914 ns | 0.25 | 0.00 | - | - | - | 32 B | - | 'Sum Linq' | 1000000 | 5,507,463.90 ns | 20,544.6872 ns | 18,212.3301 ns | 1.00 | 0.00 | - | - | - | 32 B | - | 'Sum Opt' | 1000000 | 1,437,876.07 ns | 11,039.3320 ns | 10,326.1980 ns | 0.26 | 0.00 | 3.9063 | - | - | 16509 B | + | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |-------------- |-------- |-----------------:|---------------:|---------------:|---------:|--------:|-------:|------:|------:|----------:| + | 'Sum Cistern' | 0 | 16.852 ns | 0.1372 ns | 0.1216 ns | 2.09 | 0.02 | 0.0102 | - | - | 32 B | + | 'Sum Linq' | 0 | 8.081 ns | 0.0280 ns | 0.0248 ns | 1.00 | 0.00 | - | - | - | - | + | 'Sum Opt' | 0 | 26,887.418 ns | 91.3808 ns | 76.3071 ns | 3,327.48 | 14.58 | 5.1270 | - | - | 16229 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 10 | 27.974 ns | 0.2326 ns | 0.2176 ns | 0.46 | 0.00 | 0.0102 | - | - | 32 B | + | 'Sum Linq' | 10 | 60.580 ns | 0.2447 ns | 0.2289 ns | 1.00 | 0.00 | 0.0101 | - | - | 32 B | + | 'Sum Opt' | 10 | 27,413.368 ns | 93.3849 ns | 82.7833 ns | 452.62 | 1.59 | 5.1270 | - | - | 16229 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 100 | 133.831 ns | 0.2936 ns | 0.2603 ns | 0.27 | 0.00 | 0.0100 | - | - | 32 B | + | 'Sum Linq' | 100 | 493.470 ns | 1.0039 ns | 0.9390 ns | 1.00 | 0.00 | 0.0095 | - | - | 32 B | + | 'Sum Opt' | 100 | 27,309.393 ns | 107.6157 ns | 100.6638 ns | 55.34 | 0.23 | 5.1270 | - | - | 16229 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 10000 | 11,721.675 ns | 25.7087 ns | 21.4679 ns | 0.27 | 0.00 | - | - | - | 32 B | + | 'Sum Linq' | 10000 | 43,967.113 ns | 113.4651 ns | 106.1353 ns | 1.00 | 0.00 | - | - | - | 32 B | + | 'Sum Opt' | 10000 | 39,896.225 ns | 135.1150 ns | 119.7759 ns | 0.91 | 0.00 | 5.0659 | - | - | 16229 B | + | | | | | | | | | | | | + | 'Sum Cistern' | 1000000 | 1,172,511.029 ns | 3,504.5527 ns | 3,278.1608 ns | 0.27 | 0.00 | - | - | - | 32 B | + | 'Sum Linq' | 1000000 | 4,403,267.500 ns | 16,557.6598 ns | 15,488.0453 ns | 1.00 | 0.00 | - | - | - | 32 B | + | 'Sum Opt' | 1000000 | 1,207,429.492 ns | 2,669.2049 ns | 2,496.7759 ns | 0.27 | 0.00 | 1.9531 | - | - | 16203 B | */ public partial class SumBechmarks : BenchmarkBase { @@ -41,25 +41,25 @@ public double SumCistern() /* | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | |------------------------- |-------- |----------------:|---------------:|---------------:|---------:|--------:|-------:|------:|------:|----------:| - | 'Sum of Squares Cistern' | 0 | 32.80 ns | 0.4647 ns | 0.4120 ns | 0.79 | 0.02 | 0.0101 | - | - | 32 B | - | 'Sum of Squares Linq' | 0 | 41.33 ns | 0.8723 ns | 1.0046 ns | 1.00 | 0.00 | - | - | - | - | - | 'Sum of Squares Opt' | 0 | 60,655.93 ns | 1,004.6357 ns | 939.7369 ns | 1,462.69 | 44.13 | 5.9204 | - | - | 18733 B | + | 'Sum of Squares Cistern' | 0 | 24.68 ns | 0.0478 ns | 0.0447 ns | 0.91 | 0.00 | 0.0102 | - | - | 32 B | + | 'Sum of Squares Linq' | 0 | 27.05 ns | 0.1136 ns | 0.1062 ns | 1.00 | 0.00 | - | - | - | - | + | 'Sum of Squares Opt' | 0 | 34,392.44 ns | 143.4999 ns | 127.2089 ns | 1,271.72 | 6.29 | 5.7983 | - | - | 18411 B | | | | | | | | | | | | | - | 'Sum of Squares Cistern' | 10 | 109.62 ns | 0.7830 ns | 0.7324 ns | 0.64 | 0.01 | 0.0483 | - | - | 152 B | - | 'Sum of Squares Linq' | 10 | 172.53 ns | 1.4346 ns | 1.3419 ns | 1.00 | 0.00 | 0.0150 | - | - | 48 B | - | 'Sum of Squares Opt' | 10 | 60,081.55 ns | 610.3621 ns | 570.9330 ns | 348.26 | 4.22 | 5.9204 | - | - | 18733 B | + | 'Sum of Squares Cistern' | 10 | 78.52 ns | 0.2665 ns | 0.2493 ns | 0.62 | 0.00 | 0.0280 | - | - | 88 B | + | 'Sum of Squares Linq' | 10 | 125.78 ns | 0.3848 ns | 0.3411 ns | 1.00 | 0.00 | 0.0153 | - | - | 48 B | + | 'Sum of Squares Opt' | 10 | 34,251.23 ns | 155.5150 ns | 145.4688 ns | 272.37 | 1.46 | 5.7983 | - | - | 18412 B | | | | | | | | | | | | | - | 'Sum of Squares Cistern' | 100 | 308.26 ns | 2.3056 ns | 2.1567 ns | 0.32 | 0.00 | 0.0482 | - | - | 152 B | - | 'Sum of Squares Linq' | 100 | 952.33 ns | 10.2225 ns | 9.5621 ns | 1.00 | 0.00 | 0.0143 | - | - | 48 B | - | 'Sum of Squares Opt' | 100 | 60,050.67 ns | 361.5115 ns | 338.1580 ns | 63.06 | 0.68 | 5.9204 | - | - | 18733 B | + | 'Sum of Squares Cistern' | 100 | 293.53 ns | 0.8549 ns | 0.7996 ns | 0.45 | 0.00 | 0.0277 | - | - | 88 B | + | 'Sum of Squares Linq' | 100 | 652.57 ns | 1.5209 ns | 1.3482 ns | 1.00 | 0.00 | 0.0153 | - | - | 48 B | + | 'Sum of Squares Opt' | 100 | 34,430.53 ns | 144.0165 ns | 134.7132 ns | 52.77 | 0.23 | 5.7983 | - | - | 18412 B | | | | | | | | | | | | | - | 'Sum of Squares Cistern' | 10000 | 20,931.97 ns | 108.3494 ns | 101.3501 ns | 0.24 | 0.00 | 0.0305 | - | - | 152 B | - | 'Sum of Squares Linq' | 10000 | 88,243.58 ns | 793.2973 ns | 742.0508 ns | 1.00 | 0.00 | - | - | - | 48 B | - | 'Sum of Squares Opt' | 10000 | 76,492.69 ns | 1,187.3593 ns | 1,110.6567 ns | 0.87 | 0.01 | 5.8594 | - | - | 18733 B | + | 'Sum of Squares Cistern' | 10000 | 23,535.67 ns | 48.7263 ns | 45.5786 ns | 0.40 | 0.00 | - | - | - | 88 B | + | 'Sum of Squares Linq' | 10000 | 59,171.18 ns | 156.9741 ns | 139.1534 ns | 1.00 | 0.00 | - | - | - | 48 B | + | 'Sum of Squares Opt' | 10000 | 46,917.77 ns | 251.1217 ns | 234.8994 ns | 0.79 | 0.00 | 5.7373 | - | - | 18412 B | | | | | | | | | | | | | - | 'Sum of Squares Cistern' | 1000000 | 2,078,028.80 ns | 16,876.6655 ns | 15,786.4434 ns | 0.24 | 0.00 | - | - | - | 152 B | - | 'Sum of Squares Linq' | 1000000 | 8,754,710.42 ns | 66,414.0752 ns | 62,123.7671 ns | 1.00 | 0.00 | - | - | - | 48 B | - | 'Sum of Squares Opt' | 1000000 | 1,457,266.62 ns | 12,679.7592 ns | 11,240.2762 ns | 0.17 | 0.00 | 5.8594 | - | - | 18735 B | + | 'Sum of Squares Cistern' | 1000000 | 2,347,908.31 ns | 6,746.4530 ns | 5,980.5549 ns | 0.34 | 0.00 | - | - | - | 88 B | + | 'Sum of Squares Linq' | 1000000 | 6,868,664.30 ns | 18,140.2511 ns | 15,147.9312 ns | 1.00 | 0.00 | - | - | - | 48 B | + | 'Sum of Squares Opt' | 1000000 | 1,217,121.11 ns | 4,969.3813 ns | 4,648.3623 ns | 0.18 | 0.00 | 5.8594 | - | - | 18390 B | */ public partial class SumOfSquaresBechmarks : BenchmarkBase { @@ -71,27 +71,28 @@ public double SumSqCistern() } /* - | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | - |-------------------- |-------- |-----------------:|----------------:|----------------:|---------:|--------:|----------:|------:|------:|----------:| - | 'Cartesian Cistern' | 0 | 107.11 ns | 0.3919 ns | 0.3665 ns | 1.51 | 0.01 | 0.0685 | - | - | 216 B | - | 'Cartesian Linq' | 0 | 71.01 ns | 0.6543 ns | 0.5800 ns | 1.00 | 0.00 | 0.0533 | - | - | 168 B | - | 'Cartesian Opt' | 0 | 109,861.61 ns | 481.1207 ns | 450.0406 ns | 1,547.06 | 12.58 | 11.1084 | - | - | 35050 B | - | | | | | | | | | | | | - | 'Cartesian Cistern' | 10 | 199.06 ns | 1.2596 ns | 1.1166 ns | 0.71 | 0.01 | 0.0913 | - | - | 288 B | - | 'Cartesian Linq' | 10 | 282.24 ns | 2.9057 ns | 2.7180 ns | 1.00 | 0.00 | 0.0734 | - | - | 232 B | - | 'Cartesian Opt' | 10 | 109,093.80 ns | 652.4443 ns | 610.2968 ns | 386.55 | 3.88 | 11.1084 | - | - | 35050 B | - | | | | | | | | | | | | - | 'Cartesian Cistern' | 100 | 1,036.78 ns | 6.9351 ns | 6.4871 ns | 0.30 | 0.00 | 0.0896 | - | - | 288 B | - | 'Cartesian Linq' | 100 | 3,491.20 ns | 29.3154 ns | 27.4217 ns | 1.00 | 0.00 | 0.1640 | - | - | 520 B | - | 'Cartesian Opt' | 100 | 109,082.81 ns | 813.5949 ns | 761.0372 ns | 31.25 | 0.25 | 11.1084 | - | - | 35050 B | - | | | | | | | | | | | | - | 'Cartesian Cistern' | 10000 | 86,116.90 ns | 686.6200 ns | 642.2648 ns | 0.26 | 0.00 | - | - | - | 288 B | - | 'Cartesian Linq' | 10000 | 337,411.42 ns | 3,040.0049 ns | 2,694.8852 ns | 1.00 | 0.00 | 9.7656 | - | - | 32200 B | - | 'Cartesian Opt' | 10000 | 138,558.95 ns | 1,154.6305 ns | 1,023.5498 ns | 0.41 | 0.00 | 10.9863 | - | - | 35050 B | - | | | | | | | | | | | | - | 'Cartesian Cistern' | 1000000 | 8,606,452.60 ns | 97,523.0158 ns | 91,223.0895 ns | 0.25 | 0.00 | - | - | - | 288 B | - | 'Cartesian Linq' | 1000000 | 33,758,322.92 ns | 373,052.7235 ns | 348,953.7490 ns | 1.00 | 0.00 | 1000.0000 | - | - | 3200200 B | - | 'Cartesian Opt' | 1000000 | 2,878,193.54 ns | 19,063.2906 ns | 17,831.8138 ns | 0.09 | 0.00 | 7.8125 | - | - | 35052 B |*/ + | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |-------------------- |-------- |-----------------:|---------------:|---------------:|---------:|--------:|----------:|------:|------:|----------:| + | 'Cartesian Cistern' | 0 | 90.01 ns | 0.8249 ns | 0.7313 ns | 1.40 | 0.01 | 0.0688 | - | - | 216 B | + | 'Cartesian Linq' | 0 | 64.42 ns | 0.4785 ns | 0.4476 ns | 1.00 | 0.00 | 0.0535 | - | - | 168 B | + | 'Cartesian Opt' | 0 | 65,658.98 ns | 322.1956 ns | 301.3820 ns | 1,019.30 | 8.06 | 10.8643 | - | - | 34474 B | + | | | | | | | | | | | | + | 'Cartesian Cistern' | 10 | 167.74 ns | 0.5966 ns | 0.5581 ns | 0.74 | 0.00 | 0.0918 | - | - | 288 B | + | 'Cartesian Linq' | 10 | 226.30 ns | 0.4422 ns | 0.3920 ns | 1.00 | 0.00 | 0.0739 | - | - | 232 B | + | 'Cartesian Opt' | 10 | 65,134.34 ns | 265.7659 ns | 235.5945 ns | 287.82 | 1.24 | 10.9863 | - | - | 34474 B | + | | | | | | | | | | | | + | 'Cartesian Cistern' | 100 | 862.19 ns | 2.1934 ns | 2.0517 ns | 0.31 | 0.00 | 0.0916 | - | - | 288 B | + | 'Cartesian Linq' | 100 | 2,770.59 ns | 6.3523 ns | 5.6311 ns | 1.00 | 0.00 | 0.1640 | - | - | 520 B | + | 'Cartesian Opt' | 100 | 67,920.13 ns | 213.4488 ns | 199.6601 ns | 24.51 | 0.07 | 10.8643 | - | - | 34474 B | + | | | | | | | | | | | | + | 'Cartesian Cistern' | 10000 | 73,755.52 ns | 173.7575 ns | 145.0953 ns | 0.28 | 0.00 | - | - | - | 288 B | + | 'Cartesian Linq' | 10000 | 265,771.58 ns | 706.6751 ns | 661.0243 ns | 1.00 | 0.00 | 10.2539 | - | - | 32200 B | + | 'Cartesian Opt' | 10000 | 89,407.86 ns | 251.5113 ns | 222.9582 ns | 0.34 | 0.00 | 10.8643 | - | - | 34482 B | + | | | | | | | | | | | | + | 'Cartesian Cistern' | 1000000 | 7,310,161.36 ns | 19,554.9373 ns | 16,329.2583 ns | 0.27 | 0.00 | - | - | - | 288 B | + | 'Cartesian Linq' | 1000000 | 26,870,184.17 ns | 45,236.8110 ns | 42,314.5411 ns | 1.00 | 0.00 | 1000.0000 | - | - | 3200200 B | + | 'Cartesian Opt' | 1000000 | 2,418,785.44 ns | 11,774.2764 ns | 11,013.6655 ns | 0.09 | 0.00 | 3.9063 | - | - | 34432 B | + */ public partial class CartesianBenchmarks : BenchmarkBase { [Benchmark(Description = "Cartesian Cistern")] @@ -104,27 +105,27 @@ from y in dim2 } /* - | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | - |------------------- |-------- |-----------------:|------------------:|------------------:|---------:|--------:|-----------:|----------:|----------:|------------:| - | 'Group By Cistern' | 0 | 393.8 ns | 1.753 ns | 1.554 ns | 1.48 | 0.01 | 0.2208 | - | - | 696 B | - | 'Group By Linq' | 0 | 265.7 ns | 2.048 ns | 1.815 ns | 1.00 | 0.00 | 0.1168 | - | - | 368 B | - | 'Group By Opt' | 0 | 399,551.1 ns | 2,872.557 ns | 2,686.992 ns | 1,503.77 | 18.07 | 39.0625 | - | - | 124235 B | - | | | | | | | | | | | | - | 'Group By Cistern' | 10 | 3,142.9 ns | 25.285 ns | 23.652 ns | 1.24 | 0.02 | 0.8087 | - | - | 2552 B | - | 'Group By Linq' | 10 | 2,535.5 ns | 22.280 ns | 20.841 ns | 1.00 | 0.00 | 0.6523 | - | - | 2056 B | - | 'Group By Opt' | 10 | 405,738.9 ns | 2,854.742 ns | 2,670.328 ns | 160.03 | 1.71 | 46.3867 | - | - | 147332 B | - | | | | | | | | | | | | - | 'Group By Cistern' | 100 | 25,933.3 ns | 133.420 ns | 124.801 ns | 1.14 | 0.01 | 4.7607 | - | - | 15056 B | - | 'Group By Linq' | 100 | 22,751.6 ns | 157.226 ns | 147.069 ns | 1.00 | 0.00 | 4.4861 | - | - | 14192 B | - | 'Group By Opt' | 100 | 445,883.5 ns | 4,056.576 ns | 3,794.524 ns | 19.60 | 0.23 | 53.2227 | - | - | 168420 B | - | | | | | | | | | | | | - | 'Group By Cistern' | 10000 | 5,212,502.0 ns | 26,990.373 ns | 25,246.812 ns | 0.96 | 0.01 | 242.1875 | 148.4375 | 78.1250 | 1497438 B | - | 'Group By Linq' | 10000 | 5,411,742.6 ns | 26,162.135 ns | 24,472.078 ns | 1.00 | 0.00 | 226.5625 | 109.3750 | 46.8750 | 1405855 B | - | 'Group By Opt' | 10000 | 6,185,879.8 ns | 38,216.056 ns | 35,747.323 ns | 1.14 | 0.01 | 398.4375 | 296.8750 | 296.8750 | 3016919 B | - | | | | | | | | | | | | - | 'Group By Cistern' | 1000000 | 721,762,426.7 ns | 11,219,209.587 ns | 10,494,455.608 ns | 0.93 | 0.01 | 12000.0000 | 6000.0000 | 2000.0000 | 109197016 B | - | 'Group By Linq' | 1000000 | 777,703,673.3 ns | 7,380,273.468 ns | 6,903,512.381 ns | 1.00 | 0.00 | 13000.0000 | 6000.0000 | 2000.0000 | 104646152 B | - | 'Group By Opt' | 1000000 | 780,702,233.3 ns | 12,137,050.645 ns | 11,353,004.704 ns | 1.00 | 0.01 | 16000.0000 | 6000.0000 | 2000.0000 | 169265304 B | + | Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |------------------- |-------- |-----------------:|------------------:|------------------:|---------:|--------:|-----------:|----------:|----------:|-----------:| + | 'Group By Cistern' | 0 | 314.9 ns | 1.2644 ns | 1.1827 ns | 1.74 | 0.01 | 0.1988 | - | - | 624 B | + | 'Group By Linq' | 0 | 181.3 ns | 0.4558 ns | 0.3806 ns | 1.00 | 0.00 | 0.1173 | - | - | 368 B | + | 'Group By Opt' | 0 | 236,575.6 ns | 827.2355 ns | 773.7966 ns | 1,305.04 | 4.09 | 39.0625 | - | - | 122633 B | + | | | | | | | | | | | | + | 'Group By Cistern' | 10 | 2,323.8 ns | 6.1583 ns | 5.4592 ns | 1.25 | 0.00 | 0.7858 | - | - | 2472 B | + | 'Group By Linq' | 10 | 1,856.2 ns | 4.1372 ns | 3.6675 ns | 1.00 | 0.00 | 0.6542 | - | - | 2056 B | + | 'Group By Opt' | 10 | 248,587.5 ns | 1,191.5435 ns | 1,114.5706 ns | 133.98 | 0.75 | 45.8984 | - | - | 145691 B | + | | | | | | | | | | | | + | 'Group By Cistern' | 100 | 20,043.0 ns | 74.5295 ns | 69.7150 ns | 1.06 | 0.01 | 4.7607 | - | - | 14976 B | + | 'Group By Linq' | 100 | 18,823.5 ns | 86.2172 ns | 80.6476 ns | 1.00 | 0.00 | 4.4861 | - | - | 14192 B | + | 'Group By Opt' | 100 | 280,661.8 ns | 754.1135 ns | 705.3982 ns | 14.91 | 0.07 | 52.2461 | - | - | 166780 B | + | | | | | | | | | | | | + | 'Group By Cistern' | 10000 | 4,274,076.9 ns | 17,038.5176 ns | 15,937.8399 ns | 0.93 | 0.01 | 234.3750 | 148.4375 | 78.1250 | 1235128 B | + | 'Group By Linq' | 10000 | 4,600,234.9 ns | 54,230.6699 ns | 50,727.4023 ns | 1.00 | 0.00 | 218.7500 | 101.5625 | 39.0625 | 1274839 B | + | 'Group By Opt' | 10000 | 4,851,653.2 ns | 20,640.9490 ns | 19,307.5565 ns | 1.05 | 0.01 | 398.4375 | 296.8750 | 296.8750 | 2033237 B | + | | | | | | | | | | | | + | 'Group By Cistern' | 1000000 | 597,903,566.7 ns | 9,163,144.9560 ns | 8,571,211.4771 ns | 0.87 | 0.02 | 11000.0000 | 4000.0000 | 1000.0000 | 63248008 B | + | 'Group By Linq' | 1000000 | 687,909,520.0 ns | 8,845,291.9188 ns | 8,273,891.5488 ns | 1.00 | 0.00 | 13000.0000 | 6000.0000 | 2000.0000 | 71289272 B | + | 'Group By Opt' | 1000000 | 666,151,733.3 ns | 7,902,040.9008 ns | 7,391,573.9614 ns | 0.97 | 0.02 | 17000.0000 | 7000.0000 | 3000.0000 | 61443144 B | */ public partial class GroupByBenchmarks : BenchmarkBase { @@ -140,23 +141,23 @@ public int[] GroupCistern() } /* - | Method | max | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | - |------------------------------ |----- |-------------------:|------------------:|------------------:|---------:|--------:|-------------:|------:|------:|-------------:| - | 'Pythagorean Triples Cistern' | 0 | 527.5 ns | 3.755 ns | 3.513 ns | 1.66 | 0.01 | 0.2508 | - | - | 792 B | - | 'Pythagorean Triples Linq' | 0 | 318.4 ns | 2.403 ns | 2.130 ns | 1.00 | 0.00 | 0.1574 | - | - | 496 B | - | 'Pythagorean Triples Opt' | 0 | 348,225.3 ns | 2,112.988 ns | 1,976.491 ns | 1,094.57 | 9.41 | 30.7617 | - | - | 98062 B | - | | | | | | | | | | | | - | 'Pythagorean Triples Cistern' | 10 | 8,285.1 ns | 84.632 ns | 79.165 ns | 0.80 | 0.01 | 3.5706 | - | - | 11280 B | - | 'Pythagorean Triples Linq' | 10 | 10,385.1 ns | 76.444 ns | 71.506 ns | 1.00 | 0.00 | 3.6316 | - | - | 11456 B | - | 'Pythagorean Triples Opt' | 10 | 351,490.9 ns | 2,800.651 ns | 2,619.731 ns | 33.85 | 0.38 | 30.7617 | - | - | 98070 B | - | | | | | | | | | | | | - | 'Pythagorean Triples Cistern' | 100 | 2,964,882.8 ns | 17,915.109 ns | 16,757.804 ns | 0.63 | 0.01 | 1835.9375 | - | - | 5781240 B | - | 'Pythagorean Triples Linq' | 100 | 4,695,351.8 ns | 44,031.952 ns | 41,187.515 ns | 1.00 | 0.00 | 1843.7500 | - | - | 5822096 B | - | 'Pythagorean Triples Opt' | 100 | 568,447.1 ns | 4,059.144 ns | 3,598.326 ns | 0.12 | 0.00 | 30.2734 | - | - | 98070 B | - | | | | | | | | | | | | - | 'Pythagorean Triples Cistern' | 1000 | 2,469,709,900.0 ns | 8,300,441.640 ns | 7,358,125.312 ns | 0.58 | 0.00 | 1709000.0000 | - | - | 5377404840 B | - | 'Pythagorean Triples Linq' | 1000 | 4,271,984,966.7 ns | 29,321,501.294 ns | 27,427,350.503 ns | 1.00 | 0.00 | 1710000.0000 | - | - | 5381416496 B | - | 'Pythagorean Triples Opt' | 1000 | 173,111,693.3 ns | 1,882,627.953 ns | 1,761,011.356 ns | 0.04 | 0.00 | - | - | - | 100344 B | + | Method | max | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated | + |------------------------------ |----- |-------------------:|-----------------:|------------------:|-------:|--------:|-------------:|------:|------:|-------------:| + | 'Pythagorean Triples Cistern' | 0 | 465.8 ns | 1.901 ns | 1.6856 ns | 1.83 | 0.01 | 0.2470 | - | - | 776 B | + | 'Pythagorean Triples Linq' | 0 | 254.1 ns | 1.019 ns | 0.9533 ns | 1.00 | 0.00 | 0.1578 | - | - | 496 B | + | 'Pythagorean Triples Opt' | 0 | 225,031.5 ns | 805.354 ns | 753.3290 ns | 885.73 | 4.97 | 30.7617 | - | - | 96902 B | + | | | | | | | | | | | | + | 'Pythagorean Triples Cistern' | 10 | 7,425.1 ns | 38.786 ns | 32.3877 ns | 0.77 | 0.00 | 3.5858 | - | - | 11264 B | + | 'Pythagorean Triples Linq' | 10 | 9,623.9 ns | 32.828 ns | 30.7077 ns | 1.00 | 0.00 | 3.6469 | - | - | 11456 B | + | 'Pythagorean Triples Opt' | 10 | 225,238.5 ns | 884.302 ns | 783.9105 ns | 23.40 | 0.12 | 30.7617 | - | - | 96966 B | + | | | | | | | | | | | | + | 'Pythagorean Triples Cistern' | 100 | 2,615,738.7 ns | 7,146.229 ns | 6,684.5870 ns | 0.59 | 0.00 | 1839.8438 | - | - | 5781224 B | + | 'Pythagorean Triples Linq' | 100 | 4,462,903.4 ns | 14,469.345 ns | 13,534.6342 ns | 1.00 | 0.00 | 1851.5625 | - | - | 5822096 B | + | 'Pythagorean Triples Opt' | 100 | 412,640.2 ns | 1,139.718 ns | 1,010.3302 ns | 0.09 | 0.00 | 30.2734 | - | - | 96910 B | + | | | | | | | | | | | | + | 'Pythagorean Triples Cistern' | 1000 | 2,169,828,593.3 ns | 8,159,438.780 ns | 7,632,344.0976 ns | 0.55 | 0.00 | 1714000.0000 | - | - | 5377404824 B | + | 'Pythagorean Triples Linq' | 1000 | 3,979,017,007.1 ns | 5,244,819.772 ns | 4,649,396.1160 ns | 1.00 | 0.00 | 1715000.0000 | - | - | 5381416496 B | + | 'Pythagorean Triples Opt' | 1000 | 149,938,446.4 ns | 305,989.109 ns | 271,251.3750 ns | 0.04 | 0.00 | - | - | - | 97446 B | */ public partial class PythagoreanTriplesBenchmarks { diff --git a/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj b/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj index 2484c03..f4320e0 100644 --- a/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj +++ b/benchmarks/LinqOptimizer.Benchmarks.CSharp/LinqOptimizer.Benchmarks.CSharp.csproj @@ -2,12 +2,12 @@ Exe - netcoreapp2.2 + netcoreapp3.0 - + diff --git a/benchmarks/LinqOptimizer.Benchmarks.FSharp/LinqOptimizer.Benchmarks.FSharp.fsproj b/benchmarks/LinqOptimizer.Benchmarks.FSharp/LinqOptimizer.Benchmarks.FSharp.fsproj index 930c1f8..ddd0976 100644 --- a/benchmarks/LinqOptimizer.Benchmarks.FSharp/LinqOptimizer.Benchmarks.FSharp.fsproj +++ b/benchmarks/LinqOptimizer.Benchmarks.FSharp/LinqOptimizer.Benchmarks.FSharp.fsproj @@ -1,7 +1,8 @@  - netcoreapp2.2;net461 + netcoreapp3.0 + Exe AnyCPU true true @@ -11,6 +12,10 @@ + + + + diff --git a/benchmarks/LinqOptimizer.Benchmarks.FSharp/Program.fs b/benchmarks/LinqOptimizer.Benchmarks.FSharp/Program.fs index 587eacb..c5cc38b 100644 --- a/benchmarks/LinqOptimizer.Benchmarks.FSharp/Program.fs +++ b/benchmarks/LinqOptimizer.Benchmarks.FSharp/Program.fs @@ -7,6 +7,31 @@ open System.Collections.Generic open System.Diagnostics open Nessos.LinqOptimizer.FSharp open Nessos.LinqOptimizer.Base +open Cistern.Linq.FSharp + +let measuref3<'T>(title1, action1 : unit -> 'T, title2, action2 : unit -> 'T, title3, action3 : unit -> 'T, validate : 'T * 'T -> bool) = + let sw = new Stopwatch(); + sw.Start(); + let t1 = action1(); + sw.Stop(); + Console.WriteLine("\"{0}\":\t{1}",title1, sw.Elapsed); + sw.Restart(); + let t2 = action2(); + sw.Stop(); + Console.WriteLine("\"{0}\":\t{1}", title2, sw.Elapsed); + sw.Restart(); + let t3 = action3(); + sw.Stop(); + Console.WriteLine("\"{0}\":\t{1}", title3, sw.Elapsed); + let v = validate(t1, t2) + if not v then + Console.WriteLine("Values {0}, {1}", t1, t2) + Console.WriteLine("Validate 1v2 : {0}", v); + let v = validate(t1, t3) + if not v then + Console.WriteLine("Values {0}, {1}", t1, t2) + Console.WriteLine("Validate 1v3: {0}", v); + Console.WriteLine(); let measuref<'T>(title1, action1 : unit -> 'T, title2, action2 : unit -> 'T, validate : 'T * 'T -> bool) = let sw = new Stopwatch(); @@ -27,18 +52,27 @@ let measuref<'T>(title1, action1 : unit -> 'T, title2, action2 : unit -> 'T, val let SumLinq(values : double []) = Seq.sum values +let SumCistern(values : double []) = + Linq.sum values + let SumLinqOpt(values : double[]) = values |> Query.ofSeq |> Query.sum |> Query.run let SumSqLinq(values : double[]) = values |> Seq.map (fun x -> x * x) |> Seq.sum +let SumSqCistern(values : double[]) = + values |> Linq.map (fun x -> x * x) |> Linq.sum + let SumSqLinqOpt(values : double[]) = values |> Query.ofSeq |> Query.map(fun x -> x * x) |> Query.sum |> Query.run let CartLinq (dim1 : double[], dim2 : double[]) = dim1 |> Seq.collect (fun x -> Seq.map (fun y -> x * y) dim2) |> Seq.sum +let CartCistern (dim1 : double[], dim2 : double[]) = + dim1 |> Linq.collect (fun x -> Linq.map (fun y -> x * y) dim2) |> Linq.sum + let CartLinqOpt(dim1 : double[], dim2 : double[]) = dim1 |> Query.ofSeq |> Query.collect (fun x -> Seq.map (fun y -> x * y) dim2) |> Query.sum |> Query.run @@ -50,6 +84,13 @@ let GroupLinq(values : double[]) = |> Seq.map(fun (key, vs) -> Seq.length vs) |> Seq.toArray +let GroupCistern(values : double[]) = + values + |> Linq.groupBy(fun x -> int x / 100) + |> Linq.sortBy (fun (key, vs) -> key) + |> Linq.map(fun (key, vs) -> Seq.length vs) + |> Linq.toArray + let GroupLinqOpt(values : double[]) = values |> Query.ofSeq @@ -69,7 +110,16 @@ let PythagoreanTriplesLinq(max) = |> Seq.map (fun c -> a, b, c))) |> Seq.filter (fun (a,b,c) -> a * a + b * b = c * c) |> Seq.length - + +let PythagoreanTriplesCistern(max) = + Cistern.Linq.Enumerable.Range(1, max + 1) + |> Linq.collect(fun a -> + Cistern.Linq.Enumerable.Range(a, max + 1 - a) + |> Linq.collect(fun b -> + Cistern.Linq.Enumerable.Range(b, max + 1 - b) + |> Linq.map (fun c -> a, b, c))) + |> Linq.filter (fun (a,b,c) -> a * a + b * b = c * c) + |> Linq.length let PythagoreanTriplesLinqOpt(max) = Query.range(1, max + 1) @@ -150,29 +200,34 @@ let main argv = let v = Enumerable.Range(1, 200000000).Select(fun x -> rnd.NextDouble()).ToArray() let cmp (x1, x2 : double) = Math.Abs(x1 - x2) < 1E-07 - measuref("Sum Seq", (fun () -> SumLinq v), - "Sum Opt", (fun () -> SumLinqOpt v), - cmp) + measuref3("Sum Seq", (fun () -> SumLinq v), + "Sum Cistern", (fun () -> SumCistern v), + "Sum Opt", (fun () -> SumLinqOpt v), + cmp) - measuref("Sum Squares Seq", (fun () -> SumSqLinq v), - "Sum Squares Opt", (fun () -> SumSqLinqOpt v), - cmp) + measuref3("Sum Squares Seq", (fun () -> SumSqLinq v), + "Sum Squares Cistern", (fun () -> SumSqCistern v), + "Sum Squares Opt", (fun () -> SumSqLinqOpt v), + cmp) let v1 = v.Take(v.Length / 10).ToArray() let v2 = v.Take(20).ToArray() - measuref("Cartesian Seq", (fun () -> CartLinq(v1, v2)), - "Cartesian Linq Opt", (fun () -> CartLinqOpt(v1, v2)), - cmp) + measuref3("Cartesian Seq", (fun () -> CartLinq(v1, v2)), + "Cartesian Cistern", (fun () -> CartCistern(v1, v2)), + "Cartesian Linq Opt", (fun () -> CartLinqOpt(v1, v2)), + cmp) let g = Enumerable.Range(1, 20000000).Select(fun x -> 100000000. * rnd.NextDouble() - 50000000.).ToArray() - measuref("Group Seq", (fun () -> GroupLinq g), - "Group Opt", (fun () -> GroupLinqOpt g), - fun (x, y) -> Enumerable.SequenceEqual(x, y)) + measuref3("Group Seq", (fun () -> GroupLinq g), + "Group Cistern", (fun () -> GroupCistern g), + "Group Opt", (fun () -> GroupLinqOpt g), + fun (x, y) -> Enumerable.SequenceEqual(x, y)) let n = 1000 - measuref("Pythagorean Seq", (fun () -> PythagoreanTriplesLinq n), - "Pythagorean Opt", (fun () -> PythagoreanTriplesLinqOpt n ), - fun (x, y) -> x = y) + measuref3("Pythagorean Seq", (fun () -> PythagoreanTriplesLinq n), + "Pythagorean Cistern", (fun () -> PythagoreanTriplesCistern n), + "Pythagorean Opt", (fun () -> PythagoreanTriplesLinqOpt n ), + fun (x, y) -> x = y) ////////////////////////////////////////////////////////////////////////////