/// <summary> /// Use this mode when you want to force your loops to run on a very precise timing at the cost of higher CPU usage. /// <para/> /// Heavier than <see cref="SetToStandard"/> but generates very precise per call timings. /// This mode automatically scales the spinwait window automatically based on system responsiveness to find the optimal /// value to spinwait for to stay as close as possible to the specified <see cref="MinimumElapsedTime"/>, this mode /// will force the use of more performance when the system is under load to stay as precise as possible. /// <para/> /// If you aren't sure, use <see cref="SetToStandard"/> instead. /// </summary> public void SetToPreciseAuto() { // Avoid window reset if already precise auto if (Type == ThrottlerType.PreciseAuto) { return; } Type = ThrottlerType.PreciseAuto; spinwaitWindow = 0; }
/// <summary> /// Use this mode when you want to force your loops to run on a very precise timing at the cost of a higher CPU usage. /// <para/> /// Heavier than <see cref="SetToStandard"/> but generates very precise per call timings, /// This mode uses your specified spinwait window to keep the performance cost to a maximum, it won't be able to guarantee precision if the system is under load. /// <para/> /// If you aren't sure, use <see cref="SetToStandard"/> instead. /// </summary> /// <param name="spinwaitWindowParam"> /// The maximum additional ticks to spinwait for, the larger this is the more CPU is wasted on spinwaiting but if it's too small /// we won't spinwait at all and the precision won't be guaranteed. /// </param> public void SetToPreciseManual(long spinwaitWindowParam) { Type = ThrottlerType.PreciseManual; spinwaitWindow = spinwaitWindowParam; }
/// <summary> /// Use this mode when you want to lock your loops to a precise mean maximum rate. /// <para/> /// Lighter than <see cref="SetToPreciseAuto"/> and <see cref="SetToPreciseManual"/> but is only precise on average. /// <para/> /// If you aren't sure, use this one ! /// </summary> public void SetToStandard() { Type = ThrottlerType.Standard; }