diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs index c30b33643..8aadda4c9 100644 --- a/Projects/Server/Main.cs +++ b/Projects/Server/Main.cs @@ -97,15 +97,15 @@ namespace Server if (_profileStart > 0) { - _profileTime += TickCount - _profileStart; + _profileTime += Stopwatch.GetTimestamp() - _profileStart; } - _profileStart = _profiling ? TickCount : 0; + _profileStart = _profiling ? Stopwatch.GetTimestamp() : 0; } } public static TimeSpan ProfileTime => - TimeSpan.FromMilliseconds(_profileStart > 0 ? _profileTime + (TickCount - _profileStart) : _profileTime); + TimeSpan.FromTicks(_profileStart > 0 ? _profileTime + (Stopwatch.GetTimestamp() - _profileStart) : _profileTime); public static Assembly Assembly { get; set; } diff --git a/Projects/UOContent/Commands/Object Creation/Add.cs b/Projects/UOContent/Commands/Object Creation/Add.cs index aa2a23828..e844015cf 100644 --- a/Projects/UOContent/Commands/Object Creation/Add.cs +++ b/Projects/UOContent/Commands/Object Creation/Add.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Reflection; using System.Text; using Server.Items; @@ -119,17 +120,19 @@ namespace Server.Commands return; } - var time = Core.Now; + var watch = new Stopwatch(); + watch.Start(); var built = BuildObjects(from, type, start, end, args, props, packs, outline, mapAvg); if (built > 0) { + watch.Stop(); from.SendMessage( - "{0} object{1} generated in {2:F1} seconds.", + "{0} object{1} generated in {2:F2} seconds.", built, built != 1 ? "s" : "", - (Core.Now - time).TotalSeconds + watch.Elapsed.TotalSeconds ); } else @@ -141,7 +144,7 @@ namespace Server.Commands public static void FixSetString(ref string[] args, int index) { var old = args; - args = new string[index]; + args = GC.AllocateUninitializedArray(index); Array.Copy(old, 0, args, 0, index); } @@ -149,7 +152,7 @@ namespace Server.Commands public static void FixArgs(ref string[] args) { var old = args; - args = new string[args.Length - 1]; + args = GC.AllocateUninitializedArray(args.Length - 1); Array.Copy(old, 1, args, 0, args.Length); } diff --git a/Projects/UOContent/Engines/Pathing/MovementPath.cs b/Projects/UOContent/Engines/Pathing/MovementPath.cs index edba863ad..98663a060 100644 --- a/Projects/UOContent/Engines/Pathing/MovementPath.cs +++ b/Projects/UOContent/Engines/Pathing/MovementPath.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using Server.Items; using Server.PathAlgorithms; using Server.PathAlgorithms.FastAStar; @@ -71,18 +72,18 @@ namespace Server { OverrideAlgorithm = alg; - var start = DateTime.UtcNow.Ticks; + var watch = new Stopwatch(); + watch.Start(); var path = new MovementPath(from, new Point3D(p)); - var end = DateTime.UtcNow.Ticks; - var len = Math.Round((end - start) / 10000.0, 2); + watch.Stop(); if (!path.Success) { - from.SendMessage("{0} path failed: {1}ms", name, len); + from.SendMessage("{0} path failed: {1}ms", name, watch.ElapsedMilliseconds); } else { - from.SendMessage("{0} path success: {1}ms", name, len); + from.SendMessage("{0} path success: {1}ms", name, watch.ElapsedMilliseconds); var x = from.X; var y = from.Y;