Commit 37fb348e authored by Nick Craver's avatar Nick Craver

Move Profiling.ManyThreads to FactLongRunning

parent 827fa704
...@@ -12,7 +12,7 @@ namespace StackExchange.Redis.Tests ...@@ -12,7 +12,7 @@ namespace StackExchange.Redis.Tests
{ {
public class Profiling : TestBase public class Profiling : TestBase
{ {
public Profiling(ITestOutputHelper output) : base (output) { } public Profiling(ITestOutputHelper output) : base(output) { }
[Fact] [Fact]
public void Simple() public void Simple()
...@@ -86,7 +86,7 @@ private static void AssertProfiledCommandValues(IProfiledCommand command, Connec ...@@ -86,7 +86,7 @@ private static void AssertProfiledCommandValues(IProfiledCommand command, Connec
Assert.True(command.RetransmissionReason == null, nameof(command.RetransmissionReason)); Assert.True(command.RetransmissionReason == null, nameof(command.RetransmissionReason));
} }
[Fact] [FactLongRunning]
public void ManyThreads() public void ManyThreads()
{ {
using (var conn = Create()) using (var conn = Create())
...@@ -201,6 +201,7 @@ internal class PerThreadProfiler ...@@ -201,6 +201,7 @@ internal class PerThreadProfiler
public ProfilingSession GetSession() => perThreadSession.Value; public ProfilingSession GetSession() => perThreadSession.Value;
} }
internal class AsyncLocalProfiler internal class AsyncLocalProfiler
{ {
private readonly AsyncLocal<ProfilingSession> perThreadSession = new AsyncLocal<ProfilingSession>(); private readonly AsyncLocal<ProfilingSession> perThreadSession = new AsyncLocal<ProfilingSession>();
...@@ -208,7 +209,7 @@ internal class AsyncLocalProfiler ...@@ -208,7 +209,7 @@ internal class AsyncLocalProfiler
public ProfilingSession GetSession() public ProfilingSession GetSession()
{ {
var val = perThreadSession.Value; var val = perThreadSession.Value;
if(val == null) if (val == null)
{ {
perThreadSession.Value = val = new ProfilingSession(); perThreadSession.Value = val = new ProfilingSession();
} }
...@@ -354,6 +355,7 @@ public void ProfilingMD_Ex2() ...@@ -354,6 +355,7 @@ public void ProfilingMD_Ex2()
Assert.True(perThreadTimings.All(kv => kv.Value.Count == 1000)); Assert.True(perThreadTimings.All(kv => kv.Value.Count == 1000));
} }
} }
[FactLongRunning] [FactLongRunning]
public async Task ProfilingMD_Ex2_Async() public async Task ProfilingMD_Ex2_Async()
{ {
...@@ -394,7 +396,7 @@ public async Task ProfilingMD_Ex2_Async() ...@@ -394,7 +396,7 @@ public async Task ProfilingMD_Ex2_Async()
} }
Assert.Equal(16, perThreadTimings.Count); Assert.Equal(16, perThreadTimings.Count);
foreach(var item in perThreadTimings) foreach (var item in perThreadTimings)
{ {
Assert.Equal(100, item.Count); Assert.Equal(100, item.Count);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment