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
// Ugly pure ASM version of https://github.com/aspnet/KestrelHttpServer/pull/1138 and gist https://gist.github.com/benaadams/2dd3f99230757111e91915f638067a09 | |
// Not performing better though... | |
[Benchmark] | |
public int TestFindFirstByteAVX() | |
{ | |
var vector = _vectors[ByteSet]; | |
return FindFirstByteAVX(ref vector); | |
} |
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
// .NET Code generated for the F# type: | |
// type Shape = | |
// | Rectangle of width : float * length : float | |
// | Circle of radius : float | |
// | Triangle of width : float * height : float | |
using Microsoft.FSharp.Core; | |
using System; | |
using System.Collections; | |
using System.Diagnostics; |
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
/* | |
Q: At which size is it preferrable to use binary search over a simple linear search for a small ordered set? | |
R: Under 5 elements, linear search is slightly faster (from 200% to 10% faster) | |
But in practice, not sure a switch case to select the best method is really worth it | |
Unless main usecase is having most of the time only 1-2 elements (so it could be optimized manually without a loop and switch to binary otherwise) | |
At 3-4 elements, linear is only 10-5% faster | |
Relative performance between linear and binary search: | |
size x86 x64 |
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
// From https://github.com/dotnet/coreclr/tree/edc1320180a3d68a16855da8da82f01871bf3a1d/src/mscorlib | |
// 109 Files (over a total of 974 cs files) in System.Private.CoreLib.dll (ex mscorlib.dll) | |
// are making an internal fcall/qcall to a function inside coreclr.dll | |
// In total 967 internal fcall/qcall functions are imported | |
Internal\Runtime\Augments\RuntimeThread.cs | |
Microsoft\Win32\OAVariantLib.cs | |
System\AppDomain.cs | |
System\ArgIterator.cs | |
System\Array.cs |
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
// hack for https://twitter.com/ashmind/status/871357443036467201 | |
// Write to the stack through FieldOffset and Virtual methods (no unsafe, not using System.Runtime.InteropServices directly into a method) | |
// valid only for x86-32bits (need to change int Address to long in order to have it working for x64) | |
// The basic idea is to use FieldOffset on a struct to reinterpret an object reference | |
// and using this trick to take an address on the stack that doesn't involve manipulating directly IntPtr or unsafe code... | |
using System.Runtime.InteropServices; | |
class 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
function Sleef_sinf_u10: | |
subq $184, %rsp | |
movaps %xmm15, 160(%rsp) | |
movaps %xmm14, 144(%rsp) | |
movaps %xmm13, 128(%rsp) | |
movaps %xmm12, 112(%rsp) | |
movaps %xmm11, 96(%rsp) | |
movaps %xmm10, 80(%rsp) | |
movaps %xmm9, 64(%rsp) |
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
// BenchmarkDotNet=v0.10.12, OS=Windows 10 Redstone 3 [1709, Fall Creators Update] (10.0.16299.248) | |
// Intel Core i7-4980HQ CPU 2.80GHz (Haswell), 1 CPU, 8 logical cores and 4 physical cores | |
// Frequency=2728070 Hz, Resolution=366.5595 ns, Timer=TSC | |
// [Host] : .NET Framework 4.6.1 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.2633.0 | |
// DefaultJob : .NET Framework 4.6.1 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.2633.0 | |
// | |
// | |
// Method | Mean | Error | StdDev | | |
// ------------- |----------:|----------:|----------:| | |
// VirtualCall | 0.9152 ns | 0.0393 ns | 0.0368 ns | |
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
<!-- | |
*********************************************************************************************** | |
Microsoft.Common.CurrentVersion.targets | |
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have | |
created a backup copy. Incorrect changes to this file will make it | |
impossible to load or build your projects from the command-line or the IDE. | |
This file defines the steps in the standard build process for .NET projects. It | |
contains all the steps that are common among the different .NET languages, such as |
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
// Gist that shows the difference of an interface call | |
// Two cases in this benchmark: | |
// - Dictionary that should not inline | |
// - List that should inline | |
// We are also using the enumerator to show the impact on allocation as well. | |
/* | |
Method | Mean | Error | StdDev | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op | | |
------------------- |----------:|----------:|----------:|------------:|------------:|------------:|--------------------:| | |
ProcessDictionary | 27.109 ns | 0.1258 ns | 0.1176 ns | - | - | - | - | |
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
using System.IO; | |
using Microsoft.Build.Utilities; | |
namespace TestFileTracker | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |