Advertisement
Guest User

Untitled

a guest
Mar 19th, 2013
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. public class Calculations : MonoBehaviour
  6. {
  7.     private const int ARRAY_LENGTH = 1000000;
  8.     private float totalTime = 0;
  9.  
  10.     void Start()
  11.     {
  12.         CallFewTests();
  13.     }
  14.  
  15.     void OnGUI()
  16.     {
  17.         if (totalTime > 0)
  18.         {
  19.             GUILayout.Label(totalTime.ToString("0"));
  20.         }
  21.     }
  22.  
  23.     private void CallFewTests()
  24.     {
  25.         float timeBegin = Time.realtimeSinceStartup;
  26.  
  27.         for (int i = 0; i < 100; i++)
  28.         {
  29.             MakeACake();
  30.         }
  31.  
  32.         totalTime = (Time.realtimeSinceStartup - timeBegin) * 1000;
  33.     }
  34.  
  35.     private void MakeACake()
  36.     {
  37.         for (int i = 0; i < ARRAY_LENGTH; i++)
  38.         {
  39.             GetTotalGeeksCount();
  40.         }
  41.     }
  42.  
  43.     private int GetTotalGeeksCount()
  44.     {
  45.         int a = 23;
  46.         int b = 41;
  47.         return a + b;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement