This file contains 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
var rng = new Random(42); | |
var sampleSize = 10_000_000; | |
var numbers = Enumerable.Repeat(0, sampleSize).Select(_ => rng.Next(0, Int32.MaxValue)); | |
var heads = numbers.Count(x => x % 2 == 1); | |
Console.WriteLine($"Heads: {heads}, tails: {sampleSize - heads}"); | |
// Output: Heads: 5,036,860, tails: 4,963,140 | |
var popStdDev = Math.Sqrt(0.5 * 0.5); | |
var popMean = 0.5; | |
var sampleMean = (Double)heads / sampleSize; |
This file contains 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
/* | |
* A quick and dirty micro benchmark on passing a class vs a struct vs a struct by reference | |
* | |
* This is not necessarily a good benchmark. The code will likely perform much differently | |
* under a more realistic scenario. | |
* | |
* Summary: | |
* | Method | N | Mean | Error | StdDev | Rank | | |
* |------------------------------ |-------- |------------------:|--------------:|--------------:|-----:| | |
* | BenchmarkMediumClass | 1 | 0.6700 ns | 0.0017 ns | 0.0016 ns | 2 | |