Nice tutorials https://blog.unity.com/technology/performance-benchmarking-in-unity-how-to-get-started
How to install : Unity Test Framework https://docs.unity3d.com/Packages/com.unity.test-framework@1.3/manual/index.html
Template
using NUnit.Framework;
using Unity.PerformanceTesting;
using UnityEngine;
public class ShortPerformanceTest
{
[Test, Performance]
public void RenameScripts()
{
GameObject g = new GameObject();
DoTest(() => { g.name = "" + Random.value; });
}
private void DoTest(System.Action func, System.Action setUp = null, System.Action cleanUp = null)
{
Measure.Method(() => { func();})
.WarmupCount(100)
.MeasurementCount(1000)
.IterationsPerMeasurement(5)
.GC()
.SetUp(() => { if (setUp != null) setUp(); })
.CleanUp(() => { if (cleanUp != null) cleanUp(); })
.Run();
}
}