Skip to content

Commit

Permalink
added FailReqCount property to PointLatencyCounts (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
mangystx authored May 16, 2024
1 parent 3220eb9 commit c7ac495
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
45 changes: 26 additions & 19 deletions benchmarks/TimescaleBenchmark/ReadScenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public ScenarioProps Create(string connectionString, DateTimeOffset startTime, s
fakePointLatencyCounts = faker.Generate<PointLatencyCounts>();
fakePointStatusCodes = faker.Generate<PointStatusCodes>();
fakePointStepStats = faker.Generate<PointStepStatsOk>();

var rnd = new Random();

var fakeLatencyCountsPoints = Enumerable
.Range(0, 2160)
Expand All @@ -110,10 +112,11 @@ public ScenarioProps Create(string connectionString, DateTimeOffset startTime, s
TestName = fakePointLatencyCounts.TestName,
ClusterId = fakePointLatencyCounts.ClusterId,
Scenario = fakePointLatencyCounts.Scenario,
LessOrEq800 = fakePointLatencyCounts.LessOrEq800,
More800Less1200 = fakePointLatencyCounts.More800Less1200,
MoreOrEq1200 = fakePointLatencyCounts.MoreOrEq1200
})
LessOrEq800 = rnd.Next(200, 4000) * rnd.Next(0, 2),
More800Less1200 = rnd.Next(200, 4000) * rnd.Next(0, 2),
MoreOrEq1200 = rnd.Next(200, 4000) * rnd.Next(0, 2),
FailReqCount = rnd.Next(0, 300) * rnd.Next(0, 2) * rnd.Next(0, 2)
})
.ToArray();

var fakeStatusCodesPoints = Enumerable
Expand All @@ -138,26 +141,26 @@ public ScenarioProps Create(string connectionString, DateTimeOffset startTime, s
.Select(i => new PointStepStatsOk
{
Time = startTime.AddSeconds(-5 * i),
SessionId = sessionId,
CurrentOperation = fakePointStepStats.CurrentOperation,
NodeType = fakePointStepStats.NodeType,
TestSuite = fakePointStepStats.TestSuite,
TestName = fakePointStepStats.TestName,
ClusterId = fakePointStepStats.ClusterId,
Scenario = fakePointStepStats.Scenario,
Step = fakePointStepStats.Step,
AllReqCount = fakePointStepStats.AllReqCount,
Scenario = fakePointStepStats.Scenario,

AllReqCount = rnd.Next(100, 300),
AllDataAll = fakePointStepStats.AllDataAll,

OkReqCount = fakePointStepStats.OkReqCount,
OkReqRps = fakePointStepStats.OkReqRps,
FailReqCount = rnd.Next(0, 300) * rnd.Next(0, 2) * rnd.Next(0, 2),
FailReqRps = fakePointStepStats.FailReqRps,

OkLatencyMax = fakePointStepStats.OkLatencyMax,
OkLatencyMean = fakePointStepStats.OkLatencyMean,
OkLatencyMin = fakePointStepStats.OkLatencyMin,
OkLatencyStdDev = fakePointStepStats.OkLatencyStdDev,
OkLatencyP50 = fakePointStepStats.OkLatencyP50,
OkLatencyP75 = fakePointStepStats.OkLatencyP75,
OkLatencyP95 = fakePointStepStats.OkLatencyP95,
OkLatencyP99 = fakePointStepStats.OkLatencyP99,
OkLatencyP50 = Math.Round(200 + rnd.NextDouble() * 230, 2),
OkLatencyP75 = Math.Round(210 + rnd.NextDouble() * 240, 2),
OkLatencyP95 = Math.Round(220 + rnd.NextDouble() * 250, 2),
OkLatencyP99 = Math.Round(230 + rnd.NextDouble() * 260, 2),

OkDataMin = fakePointStepStats.OkDataMin,
OkDataMean = fakePointStepStats.OkDataMean,
OkDataMax = fakePointStepStats.OkDataMax,
Expand All @@ -166,10 +169,14 @@ public ScenarioProps Create(string connectionString, DateTimeOffset startTime, s
OkDataP75 = fakePointStepStats.OkDataP75,
OkDataP95 = fakePointStepStats.OkDataP95,
OkDataP99 = fakePointStepStats.OkDataP99,
FailReqCount = fakePointStepStats.FailReqCount,
FailReqRps = fakePointStepStats.FailReqRps,

SimulationValue = fakePointStepStats.SimulationValue
SimulationValue = fakePointStepStats.SimulationValue,
SessionId = sessionId,
CurrentOperation = fakePointStepStats.CurrentOperation,
NodeType = fakePointStepStats.NodeType,
TestSuite = fakePointStepStats.TestSuite,
TestName = fakePointStepStats.TestName,
ClusterId = fakePointStepStats.ClusterId
})
.ToArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public class PointLatencyCounts : PointBase
[Column(ColumnNames.LessOrEq800)] public int LessOrEq800 { get; set; }
[Column(ColumnNames.More800Less1200)] public int More800Less1200 { get; set; }
[Column(ColumnNames.MoreOrEq1200)] public int MoreOrEq1200 { get; set; }
[Column(ColumnNames.FailReqCount)] public int FailReqCount { get; set; }
}
3 changes: 2 additions & 1 deletion src/NBomber.Sinks.Timescale/SqlQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ CREATE TABLE IF NOT EXISTS ""{LatencyCountsTableName}""
""{ColumnNames.Scenario}"" TEXT,
""{ColumnNames.LessOrEq800}"" INT,
""{ColumnNames.More800Less1200}"" INT,
""{ColumnNames.MoreOrEq1200}"" INT
""{ColumnNames.MoreOrEq1200}"" INT,
""{ColumnNames.FailReqCount}"" INT
);
SELECT create_hypertable('{LatencyCountsTableName}', by_range('{ColumnNames.Time}', INTERVAL '1 day'), if_not_exists => TRUE);
CREATE INDEX IF NOT EXISTS {ColumnNames.SessionId}_index ON {LatencyCountsTableName} ({ColumnNames.SessionId});
Expand Down
5 changes: 4 additions & 1 deletion src/NBomber.Sinks.Timescale/TimescaleDbSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,16 @@ private IEnumerable<PointStepStatsFail> MapStepsStatsFail(ScenarioStats scnStats

private PointLatencyCounts MapLatencyCount(ScenarioStats scnStats, DateTimeOffset currentTime)
{
var fR = scnStats.Fail.Request;

var point = new PointLatencyCounts
{
Time = currentTime,
LessOrEq800 = scnStats.Ok.Latency.LatencyCount.LessOrEq800,
More800Less1200 = scnStats.Ok.Latency.LatencyCount.More800Less1200,
MoreOrEq1200 = scnStats.Ok.Latency.LatencyCount.MoreOrEq1200,
Scenario = scnStats.ScenarioName
Scenario = scnStats.ScenarioName,
FailReqCount = fR.Count
};

AddTestInfoTags(point);
Expand Down

0 comments on commit c7ac495

Please sign in to comment.