-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
92 lines (76 loc) · 3.41 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
namespace Test003
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Stopwatch sw = new Stopwatch();
//MY
string widthField = "width";
string heightField = "height";
string positionField = "position";
string rotationField = "rotation";
//
// ORIGINAL BEGIN
sw.Start();
List<ReflectionClass<MyClass>> reflectors = new List<ReflectionClass<MyClass>>();
for (int i = 0; i < 1000; i++)
{
MyClass myClass = new MyClass();
ReflectionClass<MyClass> reflectionClass = new ReflectionClass<MyClass>(myClass);
reflectors.Add(reflectionClass);
}
sw.Stop();
Console.Write("ORIGINAL CODE (PART 1) in miliseconds: " + sw.Elapsed.TotalMilliseconds +"\n");
sw.Reset();
sw.Start();
for (int i = 0; i < 1000; i++)
{
for (int k = 0; k < reflectors.Count; k++)
{
int width = (int)reflectors[k].GetValue("width");
reflectors[k].SetValue("width", width + new Random().Next());
int height = (int)reflectors[k].GetValue("height");
reflectors[k].SetValue("height", height + new Random().Next());
Vector3 position = (Vector3)reflectors[k].GetValue("position");
reflectors[k].SetValue("position", position + new Vector3(10, 0, 0));
Quaternion quaternion = (Quaternion)reflectors[k].GetValue("rotation");
reflectors[k].SetValue("rotation", quaternion + new Quaternion(10, 0, 10, 0));
}
}
sw.Stop();
Console.Write("ORIGINAL CODE (PART 2) in miliseconds: " + sw.Elapsed.TotalMilliseconds + "\n");
// ORIGINAL EMD
////MY BEGIN
sw.Reset();
sw.Start();
List<ReflectionClass<MyClass>> reflectorsTARAS = new List<ReflectionClass<MyClass>>();
for (int i = 0; i < 1000; i++)
{
reflectorsTARAS.Add(new ReflectionClass<MyClass>(new MyClass()));
}
sw.Stop();
Console.Write("MY CODE (PART 1) in miliseconds: " + sw.Elapsed.TotalMilliseconds + "\n");
sw.Reset();
sw.Start();
for (int i = 0; i < 1000; i++)
{
for (int k = 0; k < reflectorsTARAS.Count; k++)
{
reflectorsTARAS[k].SetValue(widthField, (int)reflectorsTARAS[k].GetValue(widthField) + new Random().Next());
reflectorsTARAS[k].SetValue(heightField, (int)reflectorsTARAS[k].GetValue(heightField) + new Random().Next());
reflectorsTARAS[k].SetValue(positionField, (Vector3)reflectorsTARAS[k].GetValue(positionField) + new Vector3(10, 0, 0));
reflectorsTARAS[k].SetValue(rotationField, (Quaternion)reflectorsTARAS[k].GetValue(rotationField) + new Quaternion(10, 0, 10, 0));
}
}
sw.Stop();
Console.Write("MY CODE (PART 2) in miliseconds: " + sw.Elapsed.TotalMilliseconds + "\n");
/////MY END
Console.ReadKey();
}
}
}