Created
May 1, 2018 04:21
-
-
Save tsubaki/b72b6ab8d37771686febac5cfebd5cfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.Profiling; | |
public class SetVector3 : MonoBehaviour { | |
private CustomSampler samplerV3; | |
private CustomSampler samplerTransform ; | |
private CustomSampler samplerCachedTransform ; | |
int max = 10000; | |
Vector3 pos; | |
void Awake () | |
{ | |
samplerV3 = CustomSampler.Create("v3"); | |
samplerTransform = CustomSampler.Create("transform"); | |
samplerCachedTransform = CustomSampler.Create("cached transform"); | |
} | |
void Update () | |
{ | |
Vector3 source = Vector3.up; | |
pos = Vector3.zero; //reset | |
samplerV3.Begin(); // ---------------------begin----------------- | |
for (int i=0; i<max; i++) | |
{ | |
pos += source; | |
} | |
transform.position = pos; | |
samplerV3.End(); // ---------------------end----------------- | |
transform.position = Vector3.zero;//reset | |
samplerTransform.Begin(); // ---------------------begin----------------- | |
for (int i = 0; i < max; i++) | |
{ | |
transform.position += source; | |
} | |
samplerTransform.End(); // --------------------end------------------ | |
transform.position = Vector3.zero;//reset | |
samplerCachedTransform.Begin(); // -----------------begin--------------------- | |
var t = GetComponent<Transform>(); | |
for (int i = 0; i < max; i++) | |
{ | |
t.position += source; | |
} | |
samplerCachedTransform.End(); // -----------------end--------------------- | |
} | |
} |
synekto
commented
May 1, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment