Permalink
Browse files

Merge pull request #1218 from AndreyAkinshin/master

Suppression of negative Elapsed in Stopwatch, this is the comment from the Reference Source:

                    // When measuring small time periods the StopWatch.Elapsed*
                    // properties can return negative values.  This is due to
                    // bugs in the basic input/output system (BIOS) or the hardware
                    // abstraction layer (HAL) on machines with variable-speed CPUs
                    // (e.g. Intel SpeedStep).
  • Loading branch information...
migueldeicaza committed Sep 23, 2015
2 parents 28f473c + 45d5332 commit 226af94a2345f88d3170823646e1c25a276ba281
Showing with 2 additions and 0 deletions.
  1. +2 −0 mcs/class/System/System.Diagnostics/Stopwatch.cs
@@ -113,6 +113,8 @@ public void Stop ()
if (!is_running)
return;
elapsed += GetTimestamp () - started;
+ if (elapsed < 0)
+ elapsed = 0;
is_running = false;
}

0 comments on commit 226af94

Please sign in to comment.