void Render() { Benchy.Begin(); Benchy.Begin("Find main camera"); GameObject mainCamera = FindMainCamera(); Benchy.End("Find main camera"); if (mainCamera) { ParticleSystem particleSystem = mainCamera.GetComponent <ParticleSystem> (); if (particleSystem) { counter++; Benchy.Begin("Main particle system code"); if (counter >= 100) { if (!particleSystem.isPlaying) { particleSystem.Play(); } particleSystem.startColor = new Color(Random.Range(0, 255) / 255f, Random.Range(0, 255) / 255f, Random.Range(0, 255) / 255f, Random.Range(0, 255) / 255f); particleSystem.startRotation = Random.Range(0, 20); counter = 0; } Benchy.End("Main particle system code"); } } Benchy.End(); }
void CallSomeOtherMethod() { Benchy.Begin(); Benchy.Begin("Checking something on method"); // Some code could possibly have been here Benchy.End("Checking something on method"); Benchy.End(); }
void Update() { Benchy.Begin(); ManualTestSharedCallsA classA = gameObject.GetComponent <ManualTestSharedCallsA>(); classA.ThisIsASharedMethod(); Benchy.End(); }
public void ThisIsASharedMethod() { Benchy.Begin(); // A method that's as about as useful as the rest of the class :) float x = 3 * 2.3938384f; double y = Mathf.Sqrt(x); y = y + .99f; Benchy.End(); }
void Update() { Benchy.Begin(); if (counter > 100) { counter = 0; ThisIsASharedMethod(); } counter++; Benchy.End(); }
//[NeverProfileMethod] // Just another example of how to mix and match manually profiled sections with auto sections void CalculateStuff() { Benchy.Begin(); int nextNumber = Random.Range(0, 1000000); if (IsPrime(nextNumber)) { Benchy.Begin("Checking if prime already found"); if (primeNumbers.ContainsKey(nextNumber)) { primeNumbers [nextNumber] = true; } else { primeNumbers.Add(nextNumber, false); } Benchy.End("Checking if prime already found"); } int sumOfAllPrimes = primeNumbers.Sum(x => x.Key); sumOfAllPrimes += 1; CallSomeOtherMethod(); Benchy.End(); }