Skip to content

Commit 6f0d575

Browse files
authored
use Stopwatch.GetElapsedTime directly
1 parent a259704 commit 6f0d575

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/RedisRateLimiting/Concurrency/RedisConcurrencyRateLimiter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace RedisRateLimiting
1111
{
1212
public class RedisConcurrencyRateLimiter<TKey> : RateLimiter
1313
{
14-
private static readonly double TickFrequency = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
15-
1614
private readonly RedisConcurrencyManager _redisManager;
1715
private readonly RedisConcurrencyRateLimiterOptions _options;
1816
private readonly ConcurrentQueue<Request> _queue = new();
@@ -28,7 +26,7 @@ public class RedisConcurrencyRateLimiter<TKey> : RateLimiter
2826

2927
public override TimeSpan? IdleDuration => Interlocked.CompareExchange(ref _activeRequestsCount, 0, 0) > 0
3028
? null
31-
: new TimeSpan((long)((Stopwatch.GetTimestamp() - _idleSince) * TickFrequency));
29+
: Stopwatch.GetElapsedTime(_idleSince);
3230

3331
public RedisConcurrencyRateLimiter(TKey partitionKey, RedisConcurrencyRateLimiterOptions options)
3432
{

0 commit comments

Comments
 (0)