Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sukedon
Last active July 15, 2016 15:01
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 sukedon/5d2e6ed7ab62b4ff51abcf2e229102a8 to your computer and use it in GitHub Desktop.
Save sukedon/5d2e6ed7ab62b4ff51abcf2e229102a8 to your computer and use it in GitHub Desktop.
GameObjectの文字列プロパティパフォーマンスチェック用
public class StringPerformanceChecker : MonoBehaviour {
private GameObject sample;
private int examineCount = 10000;
private string targetTag = "Hoge";
// Use this for initialization
IEnumerator Start () {
sample = new GameObject();
yield return new WaitForSeconds(5f);
yield return ExamineTagCompareByPlane();
yield return new WaitForSeconds(0.5f);
yield return ExamineTagCompareByMethod();
}
IEnumerator ExamineTagCompareByPlane(){
for(int i = 0;i < examineCount; i++){
if(sample.tag == targetTag){
//Do something
}
}
yield return null;
}
IEnumerator ExamineTagCompareByMethod(){
for(int i = 0;i < examineCount; i++){
if(sample.CompareTag(targetTag)){
//Do something
}
}
yield return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment