Skip to content

Commit

Permalink
Output csv from stress test run
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Jan 23, 2012
1 parent 47ae6c8 commit 232ae60
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions SignalR.Stress/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;

namespace SignalR.Stress
{
Expand Down Expand Up @@ -60,7 +61,7 @@ static void Main(string[] args)
bus.Send("a", payload).ContinueWith(task =>
{
Interlocked.Exchange(ref _exception, task.Exception);
},
},
TaskContinuationOptions.OnlyOnFaulted);
Thread.Sleep(interval);
Expand All @@ -74,7 +75,7 @@ static void Main(string[] args)
},
TaskCreationOptions.LongRunning);

MeasureStats();
MeasureStats();

Console.ReadLine();
}
Expand Down Expand Up @@ -126,6 +127,8 @@ public static void MeasureStats()
{
_sw.Start();
_avgCalcStart = DateTime.UtcNow;
var resultsPath = Guid.NewGuid().ToString() + ".csv";
File.WriteAllText(resultsPath, "Target Rate, RPS, Peak RPS, Avg RPS\n");

_rateTimer = new Timer(_ =>
{
Expand Down Expand Up @@ -172,6 +175,9 @@ public static void MeasureStats()
var d3 = Math.Max(0, TotalRate - _avgReceivesPerSecond);
Console.WriteLine("Avg RPS: {0:0.000} (diff: {1:0.000} {2:0.00}%)", Math.Min(TotalRate, _avgReceivesPerSecond), d3, d3 * 100.0 / TotalRate);
File.AppendAllText(resultsPath, String.Format("{0}, {1}, {2}, {3}\n", TotalRate, _receivesPerSecond, _peakReceivesPerSecond, _avgReceivesPerSecond));
if (recvPerSec < long.MaxValue && recvPerSec > _peakReceivesPerSecond)
{
Interlocked.Exchange(ref _peakReceivesPerSecond, recvPerSec);
Expand Down

0 comments on commit 232ae60

Please sign in to comment.