Skip to content

Instantly share code, notes, and snippets.

View benaadams's full-sized avatar
🦆
rubber duck debugging

Ben {chmark} Adams benaadams

🦆
rubber duck debugging
View GitHub Profile
@benaadams
benaadams / StackSpace.cs
Created October 31, 2017 11:22
StackSpace.cs for CoreCLR #9068 & #9066
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
class Program
{
static void Main(string[] args)
{
@benaadams
benaadams / stackspace.asm
Created October 31, 2017 11:21
stackspace asm for CoreCLR #9068 & #9066
Successfully inlined Encoding:get_ASCII():ref (6 IL bytes) (depth 1) [below ALWAYS_INLINE size]
**************** Inline Tree
Inlines into 06000001 Program:Main(ref)
[1 IL=0000 TR=000001 0600374E] [below ALWAYS_INLINE size] Encoding:get_ASCII():ref
[0 IL=0010 TR=000005 0600375A] [FAILED: target not direct] Encoding:GetBytes(ref):ref:this
[0 IL=0021 TR=000014 0600007E] [FAILED: noinline per IL/cached result] Console:WriteLine(int)
[0 IL=0016 TR=000012 06000002] [FAILED: noinline per IL/cached result] Program:OneSpantype(ref):ubyte
[0 IL=0031 TR=000019 0600007E] [FAILED: noinline per IL/cached result] Console:WriteLine(int)
[0 IL=0026 TR=000017 06000003] [FAILED: noinline per IL/cached result] Program:LotsOfSpans(ref):ubyte
Budget: initialTime=171, finalTime=169, initialBudget=1710, currentBudget=1710
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Linq;
public class Program
{
public static async Task Main(string[] args)
{
using System;
using System.Diagnostics;
using System.Reflection;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
public class AttributeTest
{
private readonly MethodBase _markedClass_MarkedMethod;
private readonly MethodBase _markedClass_NonMarkedMethod;
Inlines into 06000010 <IntermediateAsync>d__3:MoveNext():this
[0 IL=0016 TR=000063 06000003] [FAILED: unprofitable inline] Program:DelayedAsync(int):ref
[1 IL=0021 TR=000067 06002329] [below ALWAYS_INLINE size] Task:GetAwaiter():struct:this
[2 IL=0001 TR=000140 060044FC] [below ALWAYS_INLINE size] TaskAwaiter:.ctor(ref):this
[3 IL=0029 TR=000077 060044FD] [below ALWAYS_INLINE size] TaskAwaiter:get_IsCompleted():bool:this
[4 IL=0006 TR=000162 060022FE] [below ALWAYS_INLINE size] Task:get_IsCompleted():bool:this
[5 IL=0010 TR=000174 060022FF] [below ALWAYS_INLINE size] Task:IsCompletedMethod(int):bool
[6 IL=0061 TR=000107 060044D6] [below ALWAYS_INLINE size] AsyncTaskMethodBuilder:AwaitUnsafeOnCompleted(byref,byref):this
[0 IL=0008 TR=000195 060044E1] [FAILED: too many il bytes] AsyncTaskMethodBuilder`1:AwaitUnsafeOnCompleted(byref,byref):this
[7 IL=0098 TR=000044 06004500] [below ALWAYS_INLINE size] TaskAwaiter:GetResult():this
Inlines into 06000010 <IntermediateAsync>d__3:MoveNext():this
[0 IL=0016 TR=000063 06000003] [FAILED: unprofitable inline] Program:DelayedAsync(int):ref
[1 IL=0021 TR=000067 06002329] [below ALWAYS_INLINE size] Task:GetAwaiter():struct:this
[2 IL=0001 TR=000140 060044FD] [below ALWAYS_INLINE size] TaskAwaiter:.ctor(ref):this
[3 IL=0029 TR=000077 060044FE] [below ALWAYS_INLINE size] TaskAwaiter:get_IsCompleted():bool:this
[4 IL=0006 TR=000162 060022FE] [below ALWAYS_INLINE size] Task:get_IsCompleted():bool:this
[5 IL=0010 TR=000174 060022FF] [below ALWAYS_INLINE size] Task:IsCompletedMethod(int):bool
[6 IL=0061 TR=000107 060044D7] [below ALWAYS_INLINE size] AsyncTaskMethodBuilder:AwaitUnsafeOnCompleted(byref,byref):this
[0 IL=0008 TR=000195 060044E2] [FAILED: too many il bytes] AsyncTaskMethodBuilder`1:AwaitUnsafeOnCompleted(byref,byref):this
[7 IL=0098 TR=000044 06004501] [below ALWAYS_INLINE size] TaskAwaiter:GetResult():this
@benaadams
benaadams / ThrowHelperExample.cs
Last active October 16, 2017 20:34
Throw Helper example
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.Text;
public class TextLine
{
private SourceText Text;
private int Start;
public struct AsciiString : IEquatable<AsciiString>
{
private readonly byte[] _data;
public AsciiString(byte[] bytes) => _data = bytes;
public AsciiString(string s) => _data = Encoding.ASCII.GetBytes(s);
public int Length => _data.Length;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
class Program
@benaadams
benaadams / Startup.cs
Created August 25, 2017 04:40 — forked from malekpour/Startup.cs
Iris Go vs .NET Core Kestrel in terms of HTTP performance
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore;
using Microsoft.Extensions.DependencyInjection;
public class Startup
{