Created
February 3, 2016 14:25
-
-
Save ahmadnaser/74ae5aaa4a03ca11aa94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class LevelLoader : MonoBehaviour | |
{ | |
public int calculations = 10000; | |
public int iterations = 10000; | |
public bool inAwake = true; | |
public bool inStart = true; | |
IEnumerator Start () | |
{ | |
if (inStart == true) { | |
Calculate ("Start"); | |
} | |
AsyncOperation async = Application.LoadLevelAsync ("Menu"); | |
yield return async; | |
Debug.Log ("Loading complete"); | |
} | |
void Awake () | |
{ | |
if (inAwake == true) { | |
Calculate ("Awake"); | |
} | |
} | |
string debugText = "Calculating..."; | |
private void Calculate (string funcName) | |
{ | |
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch (); | |
stopwatch.Start (); | |
Vector3 calc = Vector3.zero; | |
// Do some random calculations: | |
for (int i = 0; i < iterations; i++) { | |
calc = Vector3.zero; | |
for (int c = 0; c < calculations; c++) { | |
calc = calc + Random.onUnitSphere; | |
} | |
} | |
stopwatch.Stop (); | |
Debug.Log (stopwatch.Elapsed); | |
debugText += "\n" + funcName + ": " + stopwatch.Elapsed.ToString (); | |
} | |
private void OnGUI () | |
{ | |
GUILayout.BeginVertical ("box"); | |
GUILayout.Label (debugText); | |
GUILayout.EndVertical (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment