private void Test_Stopwatch() { //var sw = Stopwatch.StartNew(); //Log.Info($"{sw.ElapsedTicks} {sw.ElapsedMilliseconds} {sw.Elapsed}"); //Log.Info($"{sw.ElapsedTicks} {sw.ElapsedMilliseconds} {sw.Elapsed}"); //Log.Info($"{sw.ElapsedTicks} {sw.ElapsedMilliseconds} {sw.Elapsed}"); //sw.Stop(); //sw.Start(); //Log.Info($"{sw.ElapsedTicks} {sw.ElapsedMilliseconds} {sw.Elapsed}"); //sw.Stop(); //Log.Info($"{sw.ElapsedTicks} {sw.ElapsedMilliseconds} {sw.Elapsed}"); //Log.Info($"{sw.ElapsedTicks} {sw.ElapsedMilliseconds} {sw.Elapsed}"); Log.Info(""); StopwatchUtils.Start("sw1"); StopwatchUtils.Print("sw1"); StopwatchUtils.Print("sw1"); StopwatchUtils.Restart("sw1"); StopwatchUtils.Print("sw1"); StopwatchUtils.Print("sw1"); StopwatchUtils.Print("sw1"); StopwatchUtils.Stop("sw1"); Log.Info(""); }
public void Push() { if (Interlocked.CompareExchange(ref _isPush, 1, 0) == 0) { _fields["elapsed_microseconds"] = StopwatchUtils.GetElapsedMicroseconds(_currentTimestamp); _collector.Push(new Payload(new Point(_measurement, _fields, _tags, _utcTimestamp.HasValue ? _utcTimestamp : DateTime.UtcNow))); } }
IEnumerator Decay() { isdecay = true; PrintToChat("<size=18><color=#fee3b4>Запущена оптимизация карты</color></size>\nПожалуйста, ожидайте..."); int i = 0; int count = decayEntities.Count; int die = 0; int lastpercent = -1; var start = DateTime.UtcNow; decayEntities.RemoveAll(item => item == null || item.IsDestroyed); StopwatchUtils.StopwatchStart("DecaySystem"); foreach (var block in decayEntities.ToArray()) { i++; var percent = (int)(i / (float)count * 100); if (StopwatchUtils.StopwatchElapsedMilliseconds("DecaySystem") > 10 || percent != lastpercent) { StopwatchUtils.StopwatchStart("DecaySystem"); if (percent != lastpercent) { if (percent % 20 == 0) { Puts($"Идёт оптимизация карты: {percent}%"); } lastpercent = percent; yield return(new WaitForSeconds(0.2f)); } } if (Performance.report.frameRate < 150 || Performance.current.frameRate < 150 || i % 10 == 0) { yield return(new WaitForEndOfFrame()); } if (block == null) { continue; } if (block.IsDestroyed) { continue; } if (block.transform == null) { continue; } if (inZone(block.transform.position)) { continue; } if (HasCupboard(block)) { continue; } block.Hurt(block.MaxHealth() / decaySettings[block.ShortPrefabName], DamageType.Decay); if (block.IsDead()) { die++; yield return(new WaitForEndOfFrame()); } } var time = DateTime.UtcNow.Subtract(start).TotalSeconds.ToString("F2"); Puts($"count:{count} die:{die}"); PrintToChat($"<size=18><color=#fee3b4>Оптимизация карты завершена</color></size>\nОбработанно объектов: <color=#fee3b4>{count}</color>\nРазрушенно объектов: <color=#fee3b4>{die}</color>\nЗатрачено времени: <color=#fee3b4>{time}c</color>"); List <BaseCombatEntity> list = new List <BaseCombatEntity>(decayEntities.Count); i = 0; foreach (var p in decayEntities.ToArray()) { if (p != null) { list.Add(p); } if (i++ % 100 == 0) { yield return(new WaitForFixedUpdate()); } } decayEntities = list; isdecay = false; }