Skip to content

Instantly share code, notes, and snippets.

@hypeartist
hypeartist / core-imaging-playground
Created February 8, 2022 13:07
core-imaging-playground
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000
Intel Core i7-4702MQ CPU 2.20GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.101
[Host] : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT [AttachedDebugger]
ShortRun : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT
Job=ShortRun Arguments=/p:DebugType=portable IterationCount=5
LaunchCount=1 WarmupCount=5
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
@hypeartist
hypeartist / Hex2Int32.cs
Created September 13, 2021 19:45
Hex2Int32
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
namespace Repos
{
public static class Misc
using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace CoreClrDebugTarget
{
class Program
{
internal static unsafe void Main(string[] args)
{
@hypeartist
hypeartist / count_utf8_chars_rev2.cs
Last active July 20, 2022 01:06
Count .NET char instances containing in UTF8 byte array (rev2)
[Benchmark]
public int GetCharInstanceCountCustomScalar()
{
return GetCharInstanceCountCustomScalarImpl(_srcBuffer, _srcBufferlength);
}
[Benchmark]
public int GetCharInstanceCountCustomSse2()
{
return GetCharInstanceCountCustomSse2Impl(_srcBuffer, _srcBufferlength);
@hypeartist
hypeartist / gen_utf8.cs
Last active February 3, 2021 23:43
Generate set of random UTF8 chars
public struct GenStats
{
public int OneByteCharCount;
public int TwoBytesCharCount;
public int ThreeBytesCharCount;
public int FourBytesCharCount;
public int OneCharSeqCount;
public int TwoCharsSeqCount;
@hypeartist
hypeartist / count_utf8_chars.cs
Last active February 3, 2021 22:34
Count .NET char instances containing in UTF8 byte array
[Benchmark]
public int GetCharInstanceCountCustomScalar()
{
return GetCharInstanceCountCustomScalarImpl(_srcBuffer, _srcBufferlength);
}
[Benchmark]
public int GetCharInstanceCountCustomSse2()
{
return GetCharInstanceCountCustomSse2Impl(_srcBuffer, _srcBufferlength);
@hypeartist
hypeartist / .log
Created August 5, 2020 19:48
logcat
08-05 23:46:53.120 588 588 I /vendor/bin/sscrpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_pm.c:113: fastrpc_wake_lock_deinit done
08-05 23:46:53.120 588 588 I /vendor/bin/sscrpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_apps_user.c:2493: fastrpc_apps_user_deinit done
08-05 23:46:53.120 588 588 E /vendor/bin/sscrpcd: vendor/qcom/proprietary/sensors-see/sscrpcd/src/sscrpcd.cpp:89:sscrpcd daemon will restart after 25ms...
08-05 23:46:53.124 1082 1082 I /vendor/bin/adsprpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_apps_user.c:2548: fastrpc_apps_user_init done
08-05 23:46:53.124 1082 1082 I /vendor/bin/adsprpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_apps_user.c:1153: remote_handle_open: Successfully opened handle 0x56 for '":;./\attachguestos on domain 0
08-05 23:46:53.124 1082 1082 E /vendor/bin/adsprpcd: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_apps_user.c:2357: Error 0xffffffff: apps_dev_init failed
[StructLayout(LayoutKind.Sequential, Size = 256)]
public unsafe struct Bitset
{
public void Set(int bitIndex) => ((int*) Unsafe.AsPointer(ref Unsafe.AsRef(this)))[(bitIndex & ~7) >> 5] |= 1 << (bitIndex & 7);
public void Unset(int bitIndex) => ((int*)Unsafe.AsPointer(ref Unsafe.AsRef(this)))[(bitIndex & ~7) >> 5] ^= 1 << (bitIndex & 7);
public void SetAll() => Unsafe.InitBlock(Unsafe.AsPointer(ref Unsafe.AsRef(this)), 0xff, (uint) Unsafe.SizeOf<Bitset>());
public void UnsetAll() => Unsafe.InitBlock(Unsafe.AsPointer(ref Unsafe.AsRef(this)), 0x00, (uint) Unsafe.SizeOf<Bitset>());
}
@hypeartist
hypeartist / gist:d52ef1196e2f19a7b36367d95a123c3a
Created June 6, 2020 17:58
Get PEB64 without using P/Invoke
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
namespace ConsoleApp1
{
unsafe class Program
{
static void Main(string[] args)
@hypeartist
hypeartist / Simd
Last active May 23, 2020 22:52
SimdQ
public unsafe struct PixelInfo
{
public const int Shift = 8;
public const int Scale = 1 << Shift;
public const int Mask = Scale - 1;
public const int Msb = 1 << (Shift - 1);
public struct Cover
{
public const int Shift = 8;