Debug.Log Extensions
Documentation (1.1.9)

◆ StartSubStopwatch() [3/3]

static void Debug.StartSubStopwatch ( [NotNull] string  parentName,
[NotNull] string  name 
)
static

Starts a new sub-stopwatch running under a parent stopwatch. If main stopwatch by provided name does not exist yet one will be created.

void Start() { // Prints: // LoadLevel : Test . . . 14.672 s // Environment . . . 9.671 s // Terrain . . . 0.669 s // Trees . . . 1.999 s // Vegetation . . . 3 s // Actors . . . 5 s LoadLevel("Test"); }

void LoadLevel(string sceneName) { Debug.StartStopwatch($"{nameof(LoadLevel)} : {sceneName}");

SceneManager.LoadScene(sceneName); Load(LoadEnvironment); Load(LoadActors);

Debug.FinishStopwatch(); }

void LoadEnvironment() { Load(LoadTerrain);
Load(LoadTrees); Load(LoadVegetation); }

void Load(Action operation) { Debug.StartSubStopwatch(operation.Method.Name);

operation();

Debug.FinishSubStopwatch(); }

Parameters
parentNameName of parent stopwatch under which the sub-stopwatch will be nested.
nameName of new sub-stopwatch to start.