概要
using UnityEngine; using UnityEngine.Profiling; public class Example : MonoBehaviour { private CustomSampler m_sampler1; private CustomSampler m_sampler2; private CustomSampler m_sampler3; private CustomSampler m_sampler4; private void Awake() { m_sampler1 = CustomSampler.Create( "1" ); m_sampler2 = CustomSampler.Create( "2" ); m_sampler3 = CustomSampler.Create( "3" ); m_sampler4 = CustomSampler.Create( "4" ); } void Update() { int count = 6; int max = 25; m_sampler1.Begin(); var str1 = $"{count}{max}"; m_sampler1.End(); m_sampler2.Begin(); var str2 = $"{count.ToString()}{max.ToString()}"; m_sampler2.End(); m_sampler3.Begin(); var str3 = string.Format( "{0}{1}", count, max ); m_sampler3.End(); m_sampler4.Begin(); var str4 = string.Format( "{0}{1}", count.ToString(), max.ToString() ); m_sampler4.End(); } }
なんとなく気になったので調べてみた
String Interpolation は最終的には string.Format に置き換えられるので GC Alloc も同じ