Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using System.Collections;
- public class Calculations : MonoBehaviour
- {
- private const int ARRAY_LENGTH = 1000000;
- private float totalTime = 0;
- void Start()
- {
- CallFewTests();
- }
- void OnGUI()
- {
- if (totalTime > 0)
- {
- GUILayout.Label(totalTime.ToString("0"));
- }
- }
- private void CallFewTests()
- {
- float timeBegin = Time.realtimeSinceStartup;
- for (int i = 0; i < 100; i++)
- {
- MakeACake();
- }
- totalTime = (Time.realtimeSinceStartup - timeBegin) * 1000;
- }
- private void MakeACake()
- {
- for (int i = 0; i < ARRAY_LENGTH; i++)
- {
- GetTotalGeeksCount();
- }
- }
- private int GetTotalGeeksCount()
- {
- int a = 23;
- int b = 41;
- return a + b;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement