Skip to content

Instantly share code, notes, and snippets.

View MihaZupan's full-sized avatar
🍉
Genocide = bad

Miha Zupan MihaZupan

🍉
Genocide = bad
View GitHub Profile
@MihaZupan
MihaZupan / jit-diffs for changes in C# code.md
Last active January 16, 2023 18:29 — forked from EgorBo/jit-diffs for changes in C# code.md
jit-diffs for changes in C# code.md

How to run jit-diffs for changes in the managed code

All commands are in powershell, should be pretty much the same for bash and non-windows platforms

  1. build everything we're going to need:
.\build.cmd Clr+Libs -c Release ;; .\build.cmd Clr -c Checked ;; cd .\src\tests\ ;; .\build.cmd Release generatelayoutonly ;; cd ..\..
  1. Make a copy of the test core_root (will be a baseline):
using System;
using System.Diagnostics;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
// NoCheck is fine
// Offline/Online both consume a ton of memory
const X509RevocationMode RevocationCheckMode = X509RevocationMode.Offline;
Console.WriteLine(RevocationCheckMode);
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Text;
namespace ReasonPhrasesBenchmarks
{
class Program
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MihuBot.Helpers
{
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
public sealed unsafe class SpanToMemoryMemoryManager<T> : MemoryManager<T> where T : unmanaged
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Memory<T> GetMemory(Span<T> span)
{
return new SpanToMemoryMemoryManager<T>(span).Memory;
}
private readonly T* _ptr;
private readonly int _length;
public bool Equals(string value)
{
return (value != null || this == null) && string.EqualsHelper(this, value);
}
private static unsafe bool EqualsHelper(string strA, string strB)
{
int length = strA.Length;
if (length != strB.Length)
return false;
using Xunit;
namespace System.PrivateUri.Functional.Tests
{
public static class KnownSchemeTests
{
[Theory]
[InlineData("https")]
[InlineData("ws")]
[InlineData("wss")]
public const int NewLineWeight = 4;
public static void TrimDocument(MarkdownDocument document, int numberOfCharactersToKeep)
{
TrimObject(document, ref numberOfCharactersToKeep);
}
private static void TrimObject(MarkdownObject obj, ref int charactersAvailable)
{
if (obj is ContainerBlock containerBlock)
@MihaZupan
MihaZupan / CharacterCheck.cs
Last active November 2, 2019 15:28
bool IsLeftToRight(int c)
private static bool IsLeftToRight(int c)
{
// Generated from Table D.2 of RFC3454
// http://www.ietf.org/rfc/rfc3454.txt
// Probably should use a binary search approach
return c >= 0x000041 && c <= 0x00005A ||
c >= 0x000061 && c <= 0x00007A ||
c >= 0x0000C0 && c <= 0x0000D6 ||