Skip to content

Instantly share code, notes, and snippets.

@jkotas
jkotas / ClearR2RForAPIScan.csproj
Created September 24, 2023 22:36
ClearR2RForAPIScan
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@jkotas
jkotas / Program.cs
Created August 15, 2023 01:11
RW metadata lock contention
using System.Runtime.CompilerServices;
class Test
{
static int count = 0;
static void Main()
{
for (int i = 0; i < Environment.ProcessorCount; i++)
using System.Runtime.CompilerServices;
new Thread(() => F_0_0()).Start();
new Thread(() => F_1_0()).Start();
new Thread(() => F_2_0()).Start();
new Thread(() => F_3_0()).Start();
new Thread(() => F_4_0()).Start();
new Thread(() => F_5_0()).Start();
new Thread(() => F_6_0()).Start();
new Thread(() => F_7_0()).Start();
@jkotas
jkotas / Program.cs
Created March 8, 2023 03:49
Native AOT static linking demo
using System.Runtime.InteropServices;
partial class Program
{
static void Main() => Console.WriteLine(MyMethod());
[LibraryImport("MyLibrary")]
private static partial int MyMethod();
}
using System;
class G0<T> { }
class G1<T> { }
class G2<T> { }
class G3<T> { }
class G4<T> { }
class G5<T> { }
class G6<T> { }
class G7<T> { }
class G8<T> { }
using System;
struct ArrayWrapper<T>
{
T[] _value;
public ArrayWrapper(T[] value) { _value = value; }
#if true
public static readonly ArrayWrapper<T> Empty = new ArrayWrapper<T>(Array.Empty<T>());
This file has been truncated, but you can view the full file.
using System;
using System.Threading.Tasks;
class Test
{
static async Task Main()
{
int start = Environment.TickCount;
await M1000();
int end = Environment.TickCount;
@jkotas
jkotas / taskstress.cs
Created October 21, 2019 19:06
Multi-threaded Task performance test
using System;
using System.Threading.Tasks;
class Program
{
static async ValueTask<int> Step(int i)
{
if (i >= 999)
await Task.Delay(1);
else
@jkotas
jkotas / taskstress.cs
Created October 21, 2019 19:06
Multi-threaded Task performance test
using System;
using System.Threading.Tasks;
class Program
{
static async ValueTask<int> Step(int i)
{
if (i >= 999)
await Task.Delay(1);
else
#define MANUAL_SERIALIALIZATION
using System.Text;
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Json;
public class WeatherForecast