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
public class CpuLoadLimitTests | |
{ | |
private readonly int[] _data = new int[1_000_000]; | |
[Benchmark(Baseline = true)] | |
[MethodImpl(MethodImplOptions.AggressiveOptimization)] | |
public unsafe int Sum_Simple() | |
{ | |
var s0 = 0; | |
var s1 = 0; |
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
public class CpuLoadLimitTests | |
{ | |
private readonly int[] _data = new int[100_000_000]; | |
[Benchmark(Baseline = true)] | |
public unsafe int Sum_Simple() | |
{ | |
var s0 = 0; | |
var s1 = 0; | |
var s2 = 0; |
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
public class BranchElimination | |
{ | |
int[] aTab; | |
int[] xTab; | |
int[] xInpTab; | |
[GlobalSetup] | |
public void Global() | |
{ | |
aTab = new int[5] { 10, 20, 30, 40, 50 }; |
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
public static long Measure(Action a) | |
{ | |
// | |
// Quick Wormup. | |
// | |
Console.WriteLine(" [1] Warm Up ... "); | |
for (int i = 0; i < 10; i++) | |
{ | |
a(); |
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
| Method | Mean | Error | StdDev | Ratio | RatioSD | | |
|------------------------------------- |----------:|----------:|----------:|------:|--------:| | |
| SkipLinq | 47.386 ns | 0.4797 ns | 0.4487 ns | 1.00 | 0.00 | | |
| SkipHyperLinq | 31.090 ns | 0.3779 ns | 0.3350 ns | 0.66 | 0.01 | | |
| SkipLinq_Custom_List | 73.336 ns | 1.3644 ns | 1.2095 ns | 1.55 | 0.03 | | |
| SkipLinq_Custom_List_2 | 71.604 ns | 1.3169 ns | 1.4090 ns | 1.51 | 0.03 | | |
| SkipLinq_Custom_Enumerable | 48.463 ns | 0.7997 ns | 0.7089 ns | 1.02 | 0.02 | | |
| SkipLinq_Custom_Enumerable_AsClass | 40.907 ns | 0.3217 ns | 0.2687 ns | 0.86 | 0.01 | | |
| SkipLinq_Custom_Enumerable_DF_NoVirt | 2.329 ns | 0.0407 ns | 0.0340 ns | 0.05 | 0.00 | |
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
| Method | Mean | Error | StdDev | Ratio | | |
|----------- |-----------:|----------:|----------:|------:| | |
| Linq | 16.8220 ns | 0.4014 ns | 1.1582 ns | 1.00 | | |
| Last | 0.9100 ns | 0.0678 ns | 0.1797 ns | 0.06 | | |
| LastBetter | 0.8448 ns | 0.0645 ns | 0.1482 ns | 0.05 | | |
Code: | |
public class Benchmark | |
{ |
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
object[] arr = new object[] { null, "fizz", "buzz", "fizzbuzz" }; | |
int r = 0; | |
int bf = 1; | |
int bb = 1; | |
int a1, a2 = 0; | |
for (int i = 1; i < 100000000; i++) | |
{ | |
a1 = a2 = 0; |
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
#region Licence | |
/* | |
Copyright (c) 2011-2015 Bartosz Adamczewski (Bax Services) | |
MCSLock is distributed WITHOUT WARRANTY OF ANY KIND, | |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
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
class Program | |
{ | |
int MAX_NUM_LINES = 1000; | |
int ALLOC_SIZE = 0; | |
int LINE_SIZE = 64; | |
int PG_SIZE = 4096; | |
int WORD_SIZE = 8; | |
public Program() | |
{ |
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
public class Test | |
{ | |
public event EventHandler SomeEvent; | |
public void Do() | |
{ | |
SomeEvent(this, null); | |
} | |
} |
NewerOlder