Skip to content

Instantly share code, notes, and snippets.

View sebas77's full-sized avatar
🎯
Focusing

Sebastiano Mandalà sebas77

🎯
Focusing
View GitHub Profile
@sebas77
sebas77 / Test ConcurrentDictionary Allocations
Last active February 19, 2022 18:37
ConcurrentDictionary allocations make it bad for games (at least with Unity GC)
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run<Benchmarks>();
@sebas77
sebas77 / BurstHelper.cs
Last active January 25, 2024 23:27
Code to compile c# actions with Burst and use them outside the job system. Attention: it's a hack, use just for experiments only
#if UNITY_BURST_FEATURE_FUNCPTR
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using Unity.Burst;
namespace BurstHelper
void SetupEnginesAndEntities()
{
//The Engines Root is the core of Svelto.ECS. You must NEVER inject the EngineRoot
//as it is, therefore the composition root must hold a reference or it will be
//GCed.
//the UnitySumbmissionEntityViewScheduler is the scheduler that is used by the EnginesRoot to know
//when to inject the EntityViews. You shouldn't use a custom one unless you know what you
//are doing or you are not working with Unity.
_enginesRoot = new EnginesRoot(new UnitySumbmissionEntityViewScheduler());
//Engines root can never be held by anything else than the context itself to avoid leaks