CsCheck/Causal.cs
/// <summary>Marks the end of causal profiling region.</summary>
/// <param name="region">The region returned from RegionStart.</param>
Marks the end of causal profiling region.
Marks the end of causal profiling region .
public static void RegionEnd(Region region)
        {
            if (runType == RunType.Nothing) return;
            var now = Stopwatch.GetTimestamp();
            var lockTaken = false;
            spinLock.Enter(ref lockTaken);
            if (runType == RunType.CollectTimes)
            {
                times.Add((region.Name, now - region.Start));
                if (lockTaken) spinLock.Exit(false);
            }
            else
            {
                if (delayTime < 0)
                {
                    if (region.Name == delayName)
                    {
                        if (--delayCount == 0)
                        {
                            totalDelay += (now - onSince) * delayTime / -100L;
                            onSince = 0L;
                        }
                        if (lockTaken) spinLock.Exit(false);
                    }
                    else
                    {
                        var wait = now + totalDelay - region.TotalDelay
                            + ((onSince == 0L ? 0L : now - onSince)
                            + (region.OnSince == 0L ? 0L : region.OnSince - region.Start)) * delayTime / -100L;
                        if (lockTaken) spinLock.Exit(false);
                        while (Stopwatch.GetTimestamp() < wait) { };
                    }
                }
                else if (delayTime > 0 && region.Name == delayName)
                {
                    if (lockTaken) spinLock.Exit(false);
                    var wait = now + (now - region.Start) * delayTime / 100L;
                    while (Stopwatch.GetTimestamp() < wait) { };
                }
                else if (lockTaken) spinLock.Exit(false);
            }
        }
public static void RegionEnd ( Region region ) { if ( runType == RunType . Nothing ) return ; var now = Stopwatch . GetTimestamp ( ) ; var lockTaken = false ; spinLock . Enter ( ref lockTaken ) ; if ( runType == RunType . CollectTimes ) { times . Add ( ( region . Name , now - region . Start ) ) ; if ( lockTaken ) spinLock . Exit ( false ) ; } else { if ( delayTime < 0 ) { if ( region . Name == delayName ) { if ( -- delayCount == 0 ) { totalDelay += ( now - onSince ) * delayTime / - 100L ; onSince = 0L ; } if ( lockTaken ) spinLock . Exit ( false ) ; } else { var wait = now + totalDelay - region . TotalDelay + ( ( onSince == 0L ? 0L : now - onSince ) + ( region . OnSince == 0L ? 0L : region . OnSince - region . Start ) ) * delayTime / - 100L ; if ( lockTaken ) spinLock . Exit ( false ) ; while ( Stopwatch . GetTimestamp ( ) < wait ) { } ; } } else if ( delayTime > 0 && region . Name == delayName ) { if ( lockTaken ) spinLock . Exit ( false ) ; var wait = now + ( now - region . Start ) * delayTime / 100L ; while ( Stopwatch . GetTimestamp ( ) < wait ) { } ; } else if ( lockTaken ) spinLock . Exit ( false ) ; } }
Marks the end of causal profiling region.
Marks the end of causal profiling region .
region
Region
The region returned from RegionStart.
The region returned from RegionStart .