comparison Assets/Application/Scripts/Test/GetComponentTest.cs @ 8:599bd8ddb72b

Create Item Tree and Create Stage.
author Kazuma Takeda
date Tue, 17 Jan 2017 19:57:19 +0900
parents
children b55d586dd4eb
comparison
equal deleted inserted replaced
7:ad4729c5eec4 8:599bd8ddb72b
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using System.Diagnostics;
5
6 public class GetComponentTest : MonoBehaviour {
7
8 int times = 100;
9 // Use this for initialization
10 void Start () {
11
12 for (int i = 0; i < 100; i++) {
13 GameObject obj = Resources.Load<GameObject> ("Prefabs/Box/Wood");
14 }
15
16 double total_generic = 0d;
17 double total_as = 0d;
18 double total_basic = 0d;
19 double total_basic_typeof = 0d;
20
21 for(int count = 0; count < times; count++) {
22
23 Stopwatch st = new Stopwatch ();
24 st.Start ();
25 for (int i = 0; i < 10000; i++) {
26 GameObject obj = Resources.Load ("Prefabs/Box/Wood") as GameObject;
27 }
28 st.Stop ();
29 total_as += st.Elapsed.TotalMilliseconds;
30
31 // Stopwatch st = new Stopwatch ();
32 // st.Start ();
33 // for (int i = 0; i < 10000; i++) {
34 // GameObject obj = Resources.Load<GameObject> ("Prefabs/Box/Wood");
35 // }
36 // st.Stop ();
37 // total_generic += st.Elapsed.TotalMilliseconds;
38
39 // Stopwatch st = new Stopwatch ();
40 // st.Start ();
41 // for (int i = 0; i < 10000; i++) {
42 // GameObject obj = (GameObject) Resources.Load ("Prefabs/Box/Wood");
43 // }
44 // st.Stop ();
45 // total_basic += st.Elapsed.TotalMilliseconds;
46 //
47 // Stopwatch st = new Stopwatch ();
48 // st.Start ();
49 // for (int i = 0; i < 10000; i++) {
50 // GameObject obj = (GameObject) Resources.Load ("Prefabs/Box/Wood", typeof(GameObject));
51 // }
52 // st.Stop ();
53 // total_basic_typeof += st.Elapsed.TotalMilliseconds;
54 }
55
56 print ("as average : " + total_as / (double)times + "ms");
57 print ("generic average : " + total_generic / (double)times + "ms");
58 print ("basic average : " + total_basic / (double)times + "ms");
59 print ("basic typeof average : " + total_basic_typeof / (double)times + "ms");
60
61 }
62
63 // Update is called once per frame
64 void Update () {
65
66 }
67 }