[MemoryDiagnoser]
[RankColumn]
public class Operation_Benchmark
{
private static float a = 10f, buffer;
private static Random _random = new Random();
private static Stopwatch _stopwatch = new Stopwatch();
private static int RandomInt => _random.Next(10);
[Benchmark]
public void Estimate_Multiply()
{
a += RandomInt;
buffer += a * 0.5f;
}
[Benchmark]
public void Estimate_Division()
{
a += RandomInt;
buffer += a / 2f;
}
}
private static async void SaveByTimeout()
{
var timer = 0f;
var timeout = 5 * 60;
while (IsSaveByTimeout)
{
if (timer >= timeout)
{
timer = 0;
Save();
}
await Task.Yield();
timer += Time.deltaTime;
}
}