TimeUtils.cs 583 B

1234567891011121314151617181920
  1. using System.Diagnostics;
  2. namespace Aip.Service.Utils;
  3. public static class TimeUtils
  4. {
  5. public static int GetElapsedMilliseconds(DateTime start, DateTime end)
  6. {
  7. TimeSpan timeDiff = start - end;
  8. return timeDiff.Milliseconds;
  9. }
  10. public static long GetElapsedMilliseconds(long start, long stop)
  11. {
  12. return (long)((stop - start) * 1000 / (double)Stopwatch.Frequency);
  13. }
  14. public static long GetElapsedMilliseconds(long start)
  15. {
  16. return (long)((Stopwatch.GetTimestamp() - start) * 1000 / (double)Stopwatch.Frequency);
  17. }
  18. }