These are Processing sketches that I used to create VFX particle textures in a Unity project.
Usage example:
Generates a simple disk particle.
using System; | |
using Microsoft.SPOT; | |
using Microsoft.SPOT.Hardware; | |
using System.Threading; | |
using System.IO; | |
using System.Net; | |
using SecretLabs.NETMF.Hardware.Netduino; | |
using Microsoft.SPOT.Net.NetworkInformation; | |
using uPLibrary.Networking.M2Mqtt; |
using System; | |
using System.Threading; | |
namespace Cysharp.Threading.Tasks | |
{ | |
public interface IUniTaskAsyncEnumerable<out T> | |
{ | |
IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default); | |
} |
[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>()); | |
} |
There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull
example requires it.
Consider adopting the new property pattern, wherever you use IsNullOrEmpty
.
string? hello = "hello world";
Dynamic PGO (Profile-guided optimization) is a JIT-compiler optimization technique that allows JIT to collect additional information about surroundings (aka profile) in tier0 codegen in order to rely on it later during promotion from tier0 to tier1 for hot methods to make them even more efficient.
Profile-driving inlining - inliner relies on PGO data and can be very aggressive for hot paths and care less about cold ones, see dotnet/runtime#52708 and dotnet/runtime#55478. A good example where it has visible effects is this StringBuilder benchmark:
Guarded devirtualization - most monomorphic virtual/interface calls can be devirtualized using PGO data, e.g.:
void DisposeMe(IDisposable d)