/* This function converts the elapsed ticks of running performance counter to time value in unit of nanoseconds. */
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
/* This function converts the elapsed ticks of running performance counter to time value in unit of nanoseconds. */
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
{
  UINT64  Frequency;
  UINT64  NanoSeconds;
  UINT64  Remainder;
  INTN    Shift;
  Frequency = GetPerformanceCounterProperties (NULL, NULL);
  NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u);
  Shift        = MAX (0, HighBitSet64 (Remainder) - 33);
  Remainder    = RShiftU64 (Remainder, (UINTN)Shift);
  Frequency    = RShiftU64 (Frequency, (UINTN)Shift);
  NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
  return NanoSeconds;
}