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
i am text |
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
from __future__ import annotations | |
from typing import List, TypeVar, Generic, Callable, Dict, Any, TextIO, Iterable, Tuple | |
from functools import wraps, partial | |
from dataclasses import dataclass | |
from enum import Enum | |
from copy import deepcopy | |
import re | |
import operator | |
import importlib | |
import os |
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
internal unsafe sealed class Win32EventTaskSource : IValueTaskSource | |
{ | |
private IntPtr _hEvent; | |
public Win32EventTaskSource(IntPtr hEvent) => _hEvent = hEvent; | |
public void GetResult(short token) | |
{ | |
_ = WaitForSingleObject(_hEvent, 0) switch | |
{ |
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
public readonly struct GenerationalHandle | |
{ | |
public readonly uint Generation; | |
public readonly uint Handle; | |
public GenerationalHandle(uint generation, uint handle) | |
{ | |
Generation = generation; | |
Handle = handle; | |
} |
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
public unsafe class FileSystemDictionary<TValue> : IDictionary<string, TValue> | |
{ | |
private DirectoryInfo _directory; | |
public string Name { get; private set; } | |
public FileSystemDictionary(string? name = null) | |
{ | |
Name = name ?? Guid.NewGuid().ToString(); | |
_directory = Directory.CreateDirectory(Path.Join(Path.GetTempPath(), Name)); | |
} |
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
public class IsPow2Benchmark | |
{ | |
private const int Iterations = 1024; | |
public int[] Values { get; } = new int[Iterations]; | |
private volatile bool _result; | |
public enum DataType { Zero, Random, UniformPow2, UniformNonPow2, UniformNegative, Alternating, AlternatingSign } | |
[Params(DataType.Zero, DataType.Random, DataType.UniformPow2, DataType.UniformNonPow2, DataType.UniformNegative, DataType.Alternating, DataType.AlternatingSign)] |
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
from enum import Enum | |
from random import choice | |
from typing import List | |
from tkinter import * | |
class PlayerState(Enum): | |
PLAYING = 0 | |
LOST = 1 | |
WIN = 2 |
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
fixed (int* pSrcA = &MemoryMarshal.GetArrayDataReference(a)) | |
fixed (int* pSrcB = &MemoryMarshal.GetArrayDataReference(b)) | |
fixed (int* pRes = &MemoryMarshal.GetArrayDataReference(res)) | |
{ | |
var alignedRes = (int*)(((ulong)pRes + 31) & ~31ul); | |
var diff = alignedRes - pRes; | |
// unaligned block | |
{ | |
var block0 = Avx2.LoadVector256(pSrcA); |
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
public class InvokeBenchmark | |
{ | |
[Benchmark] | |
public void Native() => NativeDivDivDiv(uint.MaxValue, 15, 16, 55); | |
[DllImport(@"C:\Users\johnk\source\repos\InvokeBenchmarkNative.exe")] | |
[SuppressGCTransition] | |
public static extern uint NativeDivDivDiv(uint a, uint b, uint c, uint d); | |
[Benchmark] |
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
/* | |
* K, quick debrief on how PIX works cuz y'all gonna need to know to understand this codebase. | |
* | |
* I am certainly going to be wrong at least somwhere here. Please correct if you realise I am | |
* | |
* First and foremost, perf is absolutely critical here. Don't get clever and start optimising the generics | |
* with params object[] | |
* | |
* PIX has 2 types of events/markers |
NewerOlder