Skip to content

Commit

Permalink
time based stopwatch
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Jan 2, 2024
1 parent 867bb25 commit 74a0f0c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using Snowflake.Data.Client;
Expand Down Expand Up @@ -113,7 +111,7 @@ public void TestWaitForTheIdleConnectionWhenExceedingMaxConnectionsLimit()
pool.SetWaitingTimeout(1000);
var conn1 = OpenedConnection(connectionString);
var conn2 = OpenedConnection(connectionString);
var watch = new Stopwatch();
var watch = new StopWatch();

// act
watch.Start();
Expand Down Expand Up @@ -145,7 +143,7 @@ public void TestWaitForTheIdleConnectionWhenExceedingMaxConnectionsLimitAsync()
pool.SetWaitingTimeout(1000);
var conn1 = OpenedConnection(connectionString);
var conn2 = OpenedConnection(connectionString);
var watch = new Stopwatch();
var watch = new StopWatch();

// act
watch.Start();
Expand Down Expand Up @@ -180,7 +178,7 @@ public void TestWaitInAQueueForAnIdleSession()
.NewThread("B", 50, 2000, true)
.NewThread("C", 100, 0, true)
.NewThread("D", 150, 0, true);
var watch = new Stopwatch();
var watch = new StopWatch();

// act
watch.Start();
Expand Down
25 changes: 25 additions & 0 deletions Snowflake.Data.Tests/Util/StopWatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

namespace Snowflake.Data.Tests.Util
{
internal class StopWatch
{
private long _startMillis;
private long _stopMillis;

public long ElapsedMilliseconds
{
get => _stopMillis - _startMillis;
}

public void Start()
{
_startMillis = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
}

public void Stop()
{
_stopMillis = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
}
}
}

0 comments on commit 74a0f0c

Please sign in to comment.