Advertisement
Guest User

Untitled

a guest
Oct 30th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.12 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using Pathfinding;
  4.  
  5. public class PropertyProfile : MonoBehaviour {
  6.    
  7.     class A {
  8.        
  9.         public int val1;
  10.         public double val2;
  11.         public string val3;
  12.         public Matrix4x4 val4;
  13.        
  14.        
  15.         public int Val1 {
  16.            
  17.             get {
  18.                 return val1;
  19.             }
  20.            
  21.             set {
  22.                 val1 = value;
  23.             }
  24.         }
  25.        
  26.         public Matrix4x4 ValM4 {
  27.            
  28.             get {
  29.                 return val4;
  30.             }
  31.            
  32.             set {
  33.                 val4 = value;
  34.             }
  35.         }
  36.        
  37.         public double Val2 {
  38.            
  39.             get {
  40.                 return val2;
  41.             }
  42.            
  43.             set {
  44.                 val2 = value;
  45.             }
  46.         }
  47.        
  48.         public string Val3 {
  49.            
  50.             get {
  51.                 return val3;
  52.             }
  53.            
  54.             set {
  55.                 val3 = value;
  56.             }
  57.         }
  58.        
  59.        
  60.         public int Val4 {
  61.            
  62.             get {
  63.                 return val1 & 31;
  64.             }
  65.            
  66.             set {
  67.                 val1 = value & 15;
  68.             }
  69.         }
  70.        
  71.         public double Val5 {
  72.            
  73.             get {
  74.                 return val2 + 0.5;
  75.             }
  76.            
  77.             set {
  78.                 val2 = value - 0.5;
  79.             }
  80.         }
  81.        
  82.         public string Val6 {
  83.            
  84.             get {
  85.                 return val3;
  86.             }
  87.            
  88.             set {
  89.                 val3 = value;
  90.             }
  91.         }
  92.     }
  93.    
  94.     // Use this for initialization
  95.     void Start () {
  96.        
  97.        
  98.        
  99.         for (int t=0;t<5;t++) {
  100.            
  101.             Profile p1 = new Profile("Fields");
  102.             Profile p2 = new Profile("Props");
  103.             Profile p3 = new Profile("Fields Complex");
  104.             Profile p4 = new Profile("Props Complex");
  105.             Profile p5 = new Profile("Fields Large Struct");
  106.             Profile p6 = new Profile("Props Large Struct");
  107.             string[] mah = {""+t," astfas"+t};
  108.            
  109.             A a = new A();
  110.             a.Val1 = 2;
  111.             a.Val2 = 42.2;
  112.             a.Val3 = "here";
  113.            
  114.             int c = 0;
  115.             p1.Start();
  116.             for (int i=0;i<100000;i++) {
  117.                 a.val1 = i;
  118.                 a.val2 = i;
  119.                 a.val3 = mah[i % 2];
  120.                 c += (a.val1) + (int)(a.val2);
  121.             }
  122.             p1.Stop();
  123.            
  124.             Debug.Log (c);
  125.             c = 0;
  126.            
  127.             a.Val1 = 2;
  128.             a.Val2 = 42.2;
  129.             a.Val3 = "here";
  130.            
  131.             p2.Start();
  132.             for (int i=0;i<100000;i++) {
  133.                 a.Val1 = i;
  134.                 a.Val2 = i;
  135.                 a.Val3 = mah[i % 2];
  136.                 c += a.Val1 + (int)a.Val2;
  137.             }
  138.             p2.Stop();
  139.            
  140.             Debug.Log (c);
  141.            
  142.            
  143.             ///////
  144.            
  145.            
  146.             a.Val1 = 2;
  147.             a.Val2 = 42.2;
  148.             a.Val3 = "here";
  149.             c = 0;
  150.            
  151.             p3.Start();
  152.             for (int i=0;i<100000;i++) {
  153.                 a.val1 = i & 15;
  154.                 a.val2 = i - 0.5;
  155.                 a.val3 = mah[i % 2];
  156.                 c += (a.val1 & 31) + (int)(a.val2 + 0.5);
  157.             }
  158.             p3.Stop();
  159.            
  160.             Debug.Log (c);
  161.             c = 0;
  162.            
  163.             a.Val1 = 2;
  164.             a.Val2 = 42.2;
  165.             a.Val3 = "here";
  166.            
  167.             p4.Start();
  168.             for (int i=0;i<100000;i++) {
  169.                 a.Val4 = i;
  170.                 a.Val5 = i;
  171.                 a.Val6 = mah[i % 2];
  172.                 c += a.Val4 + (int)a.Val5;
  173.             }
  174.             p4.Stop();
  175.            
  176.             Debug.Log (c);
  177.            
  178.            
  179.             a.Val1 = 2;
  180.             a.Val2 = 42.2;
  181.             a.Val3 = "here";
  182.             a.ValM4 = Matrix4x4.identity;
  183.            
  184.             p5.Start();
  185.             for (int i=0;i<100000;i++) {
  186.                 c += a.val4.isIdentity ? 1 : 0;
  187.             }
  188.             p5.Stop();
  189.            
  190.             a.Val1 = 2;
  191.             a.Val2 = 42.2;
  192.             a.Val3 = "here";
  193.             a.ValM4 = Matrix4x4.identity;
  194.            
  195.             p6.Start();
  196.             for (int i=0;i<100000;i++) {
  197.                 c += a.ValM4.isIdentity ? 1 : 0;
  198.             }
  199.             p6.Stop();
  200.            
  201.             p1.Log();
  202.             p2.Log();
  203.             p3.Log();
  204.             p4.Log();
  205.             p5.Log();
  206.             p6.Log();
  207.         }
  208.        
  209.        
  210.     }
  211.    
  212.     // Update is called once per frame
  213.     void Update () {
  214.         Start();
  215.     }
  216. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement