Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created May 1, 2018 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/b72b6ab8d37771686febac5cfebd5cfa to your computer and use it in GitHub Desktop.
Save tsubaki/b72b6ab8d37771686febac5cfebd5cfa to your computer and use it in GitHub Desktop.
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
Copy link

synekto commented May 1, 2018

28459260_1616772308377738_527432885_n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment