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; | |
using System.Threading.Tasks; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
using System.Threading; | |
// Taking this lock on the same thread repeatedly is very fast because of it has no interlocked operations. | |
// Switching the thread where the lock is taken is expensive because of allocation and FlushProcessWriteBuffers. | |
class AsymmetricLock | |
{ |
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; | |
using System.Runtime.CompilerServices; | |
using Internal.Runtime.Augments; | |
class Program | |
{ | |
static void Fill(ConditionalWeakTable<object,object> cwt) | |
{ | |
Object[] o = new object[1000000]; | |
for (int i = 0; i < o.Length; i++) |
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
@pushd bin\Release\netcoreapp2.0\win7-x64\publish | |
rem !!! 2.0.0-preview2-002093-00 version below needs to be updated to the version actually used by the app !!! | |
copy %userprofile%\.nuget\packages\runtime.win-x64.microsoft.netcore.app\2.0.0-preview2-002093-00\tools\crossgen.exe | |
@FOR %%I in (*.dll) DO call :RunCrossGen %%~nI | |
del crossgen.exe | |
popd |
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
// csc /noconfig /nostdlib /r:System.Private.CoreLib.dll test.cs | |
using System; | |
using Internal.Runtime.Augments; | |
class My { | |
static void Work() { | |
for (;;) GC.Collect(); | |
} |
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; | |
using System.Security; | |
using System.Runtime.InteropServices; | |
class Test | |
{ | |
[DllImport("kernel32.dll")] | |
[SuppressUnmanagedCodeSecurityAttribute] | |
extern static int GetTickCount(); |
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; | |
using System.Reflection.Emit; | |
using System.Threading; | |
class Program | |
{ | |
static Barrier b = new Barrier(Environment.ProcessorCount + 1); | |
static void Work() | |
{ |
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; | |
class Program | |
{ | |
static int s; | |
static void m0(bool f) { if (!f) return; s*=3; s/=4; s*=5; s/=6; s*=7; s/=8; s*=9; } | |
static void m1(bool f) { if (!f) return; s*=3; s/=4; s*=5; s/=6; s*=7; s/=8; s*=9; } | |
static void m2(bool f) { if (!f) return; s*=3; s/=4; s*=5; s/=6; s*=7; s/=8; s*=9; } | |
static void m3(bool f) { if (!f) return; s*=3; s/=4; s*=5; s/=6; s*=7; s/=8; s*=9; } |
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; | |
using System.Runtime.InteropServices; | |
[Guid("00000002-0000-0000-C000-000000000046")] | |
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | |
interface IMalloc | |
{ | |
[PreserveSig] | |
IntPtr Alloc(IntPtr cb); | |
[PreserveSig] |
This file has been truncated, but you can view the full file.
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; | |
using System.Reflection; | |
using System.Diagnostics; | |
using System.Collections.Generic; | |
using System.Runtime.CompilerServices; | |
using Builder = System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>; | |
// using Awaiter = System.Runtime.CompilerServices.TaskAwaiter<string>; | |
// using Awaiter = System.Runtime.CompilerServices.TaskAwaiter; |
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; | |
using System.Collections.Generic; | |
class MyBase : IEquatable<MyBase> | |
{ | |
public string X { get; set; } | |
public override bool Equals(object other) | |
{ | |
MyBase o = other as MyBase; | |
return (o != null) && Equals(o); |