少年修仙传客户端基础资源
lwb
2021-01-26 f10c768723fda22f62f26833bdaa672baa3dc322
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using UnityEngine;
 
namespace HotFix_Project
{
    class TestValueType
    {
        public static void RunTest()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            //Debug.Log("测试Vector3的各种运算");
            Vector3 a = new Vector3(1, 2, 3);
            Vector3 b = Vector3.one;
 
            Debug.Log("a + b = " + (a + b));
            Debug.Log("a - b = " + (a - b));
            Debug.Log("a * 2 = " + (a * 2));
            Debug.Log("2 * a = " + (2 * a));
            Debug.Log("a / 2 = " + (a / 2));
            Debug.Log("-a = " + (-a));
            Debug.Log("a == b = " + (a == b));
            Debug.Log("a != b = " + (a != b));
            Debug.Log("a dot b = " + Vector3.Dot(a, b));
            Debug.Log("a cross b = " + Vector3.Cross(a, b));
            Debug.Log("a distance b = " + Vector3.Distance(a, b));
            Debug.Log("a.magnitude = " + a.magnitude);
            Debug.Log("a.normalized = " + a.normalized);
            Debug.Log("a.sqrMagnitude = " + a.sqrMagnitude);
 
            sw.Start();
            float dot = 0;
            for(int i = 0; i < 100000; i++)
            {
                a += Vector3.one;
                dot += Vector3.Dot(a, Vector3.zero);
            }
            sw.Stop();
 
            Debug.LogFormat("Value: a={0},dot={1}, time = {2}ms", a, dot, sw.ElapsedMilliseconds);
        }
 
        public static void RunTest2()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            //Debug.Log("测试Vector3的各种运算");
            Quaternion a = new Quaternion(1, 2, 3, 4);
            Quaternion b = Quaternion.identity;
            Vector3 c = new Vector3(2, 3, 4);
 
            Debug.Log("a * b = " + (a * b));
            Debug.Log("a * c = " + (a * c));
            Debug.Log("a == b = " + (a == b));
            Debug.Log("a != b = " + (a != b));
            Debug.Log("a dot b = " + Quaternion.Dot(a, b));
            Debug.Log("a angle b = " + Quaternion.Angle(a, b));
            Debug.Log("a.eulerAngles = " + a.eulerAngles);
            Debug.Log("Quaternion.Euler(c) = " + Quaternion.Euler(c));
            Debug.Log("Quaternion.Euler(2,3,4) = " + Quaternion.Euler(2, 3, 4));
 
            sw.Start();
            var rot = Quaternion.Euler(c);
            float dot = 0;
            for (int i = 0; i < 100000; i++)
            {
                a *= rot;
                dot += Quaternion.Dot(a, b);
            }
            sw.Stop();
 
            Debug.LogFormat("Value: a={0},dot={1}, time = {2}ms", a, dot, sw.ElapsedMilliseconds);
        }
 
        public static void RunTest3()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            //Debug.Log("测试Vector2的各种运算");
            Vector2 a = new Vector2(1, 2);
            Vector2 b = Vector2.one;
 
            Debug.Log("a + b = " + (a + b));
            Debug.Log("a - b = " + (a - b));
            Debug.Log("a * 2 = " + (a * 2));
            Debug.Log("2 * a = " + (2 * a));
            Debug.Log("a / 2 = " + (a / 2));
            Debug.Log("-a = " + (-a));
            Debug.Log("a == b = " + (a == b));
            Debug.Log("a != b = " + (a != b));
            Debug.Log("(Vector3)a = " + ((Vector3)a));
            Debug.Log("(Vector2)Vector3.one = " + ((Vector2)Vector3.one));
            Debug.Log("a dot b = " + Vector2.Dot(a, b));
            Debug.Log("a distance b = " + Vector2.Distance(a, b));
            Debug.Log("a.magnitude = " + a.magnitude);
            Debug.Log("a.normalized = " + a.normalized);
            Debug.Log("a.sqrMagnitude = " + a.sqrMagnitude);
 
            sw.Start();
            float dot = 0;
            for (int i = 0; i < 100000; i++)
            {
                a += Vector2.one;
                dot += Vector2.Dot(a, Vector2.zero);
            }
            sw.Stop();
 
            Debug.LogFormat("Value: a={0},dot={1}, time = {2}ms", a, dot, sw.ElapsedMilliseconds);
        }
    }
}