Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1452 | chris | 1 | #region --- License --- |
| 2 | /* Copyright (c) 2006, 2007 Stefanos Apostolopoulos |
||
| 3 | * See license.txt for license info |
||
| 4 | */ |
||
| 5 | #endregion |
||
| 6 | |||
| 7 | using System; |
||
| 8 | using System.Collections.Generic; |
||
| 9 | using System.Text; |
||
| 10 | using System.Diagnostics; |
||
| 11 | |||
| 12 | namespace Examples.Tests |
||
| 13 | { |
||
| 14 | [Example("Math speed test", ExampleCategory.OpenTK, "Test", Visible = false)] |
||
| 15 | public class MathSpeed |
||
| 16 | { |
||
| 17 | public static void Main() |
||
| 18 | { |
||
| 19 | /* |
||
| 20 | Stopwatch watch = new Stopwatch(); |
||
| 21 | |||
| 22 | Vector3 a = new Vector3(0.0f, 0.0f, 0.0f); |
||
| 23 | Vector3 b = new Vector3(1.0f, 1.0f, 1.0f); |
||
| 24 | Vector3 c = new Vector3(3.0f, 3.0f, 3.0f); |
||
| 25 | Vector3 d = new Vector3(4.0f, 4.0f, 4.0f); |
||
| 26 | Vector3 e = Vector3.Zero; |
||
| 27 | Vector3 res; |
||
| 28 | |||
| 29 | // Force the JIT to compile the functions. |
||
| 30 | Vector3.Add(a, b); |
||
| 31 | Vector3.Add(ref a, ref b, out res); |
||
| 32 | res = a + b; |
||
| 33 | res = Vector3.Zero; |
||
| 34 | |||
| 35 | watch.Reset(); |
||
| 36 | watch.Start(); |
||
| 37 | for (int i = 100000000; --i != 0; ) |
||
| 38 | ; |
||
| 39 | watch.Stop(); |
||
| 40 | Trace.WriteLine(String.format("Noop\t\t\t\t\t\t{0}ns", (watch.Elapsed.TotalSeconds / 10.0).ToString())); |
||
| 41 | |||
| 42 | watch.Reset(); |
||
| 43 | watch.Start(); |
||
| 44 | for (int i = 100000000; --i != 0; ) |
||
| 45 | res = Vector3.Add(res, a); |
||
| 46 | watch.Stop(); |
||
| 47 | res += res; // To make sure the whole for-loop isn't optimized-out |
||
| 48 | Trace.WriteLine(String.format("res = Vector3.Add(a, b)\t\t\t{0}ns", (watch.Elapsed.TotalSeconds / 10.0).ToString())); |
||
| 49 | res = Vector3.Zero; |
||
| 50 | |||
| 51 | watch.Reset(); |
||
| 52 | watch.Start(); |
||
| 53 | for (int i = 100000000; --i != 0; ) |
||
| 54 | res = res + a; |
||
| 55 | watch.Stop(); |
||
| 56 | res += res; // To make sure the whole for-loop isn't optimized-out |
||
| 57 | Trace.WriteLine(String.format("res = a + b\t\t\t\t\t{0}ns", (watch.Elapsed.TotalSeconds / 10.0).ToString())); |
||
| 58 | |||
| 59 | watch.Reset(); |
||
| 60 | watch.Start(); |
||
| 61 | for (int i = 100000000; --i != 0; ) |
||
| 62 | Vector3.Add(ref res, ref a, out res); |
||
| 63 | watch.Stop(); |
||
| 64 | res += res; // To make sure the whole for-loop isn't optimized-out |
||
| 65 | Trace.WriteLine(String.format("Vector3.Add(ref a, ref b, out res)\t{0}ns", (watch.Elapsed.TotalSeconds / 10.0).ToString())); |
||
| 66 | */ |
||
| 67 | /* |
||
| 68 | a = Vector3.UnitX; |
||
| 69 | b = Vector3.UnitY; |
||
| 70 | res = Vector3.Add(ref a, ref b); |
||
| 71 | Trace.WriteLine(res.ToString()); |
||
| 72 | |||
| 73 | a = Vector3.UnitX; |
||
| 74 | b = Vector3.UnitY; |
||
| 75 | Vector3.Add(a, b, out res); |
||
| 76 | Trace.WriteLine(res.ToString()); |
||
| 77 | |||
| 78 | Vector2Im q = new Vector2(0.0f, 1.0f); |
||
| 79 | Vector2Im p = new Vector2(2.0f, 3.0f); |
||
| 80 | Vector2Im s = Vector2.Add(p, q); |
||
| 81 | p = s + q; |
||
| 82 | */ |
||
| 83 | } |
||
| 84 | |||
| 85 | //static Vector3 pos = new Vector3(); |
||
| 86 | |||
| 87 | //static Vector3 Pos |
||
| 88 | //{ |
||
| 89 | // get { return pos; } |
||
| 90 | // set { pos = value; } |
||
| 91 | //} |
||
| 92 | } |
||
| 93 | } |