Simplified C# binary-trees submission
CONTRIBUTE SOURCE CODE
Provide a helpful Title
C# binary-trees by Arseniy Zlobintsev
Attach your source code file
BinaryTrees.cs BinaryTrees.csproj .csproj flags match what the suite is already using for other C# submissions.
Provide an example build command-line
❯ dotnet publish -o . (base)
Restore complete (0.3s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
BinaryTrees succeeded (3.4s) →
Build succeeded in 3.9s
❯ ./BinaryTrees 21 >> /dev/null # Single run to warm-up read cache and macOS binary validation(?)
❯ time ./BinaryTrees 21 (base)
stretch tree of depth 22 check: 8388607
2097152 trees of depth 4 check: 65011712
524288 trees of depth 6 check: 66584576
131072 trees of depth 8 check: 66977792
32768 trees of depth 10 check: 67076096
8192 trees of depth 12 check: 67100672
2048 trees of depth 14 check: 67106816
512 trees of depth 16 check: 67108352
128 trees of depth 18 check: 67108736
32 trees of depth 20 check: 67108832
long lived tree of depth 21 check: 4194303
________________________________________________________
Executed in 1.93 secs fish external
usr time 7.23 secs 0.07 millis 7.23 secs
sys time 0.32 secs 1.05 millis 0.32 secs
Environment
macOS 15.0 24A5309e arm64
Apple M1 Pro
.NET SDK: 9.0.100-rc.1.24406.4
.NET Target: 8.0.4 (LTS)
Discussion
First and foremost, thank you for making BenchmarksGame! I like that it clearly distinguishes CPU and wall-clock time tradeoff as well as LOC and their relative complexity.
This submission is an adoption of cheaper approach to binary trees which also leverages all processor cores, matching other submissions. It also leverages newer idiomatic C# syntax for a terser and simpler implementation. Let me know if you have any concerns.
Edited by Arseniy Zlobintsev