-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
312 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { errorLineSettings, networkLineSettings, threadLineSettings, throughputLineSettings } from "../graphs/item-detail"; | ||
import { bytesToMbps } from "../item-detail/calculations"; | ||
import { Metrics } from "../item-detail/metrics"; | ||
|
||
export const getChartLines = (plot): ChartLines => { | ||
const { | ||
threads, overallTimeResponse, | ||
overallThroughput, overAllFailRate, overAllNetworkV2, | ||
responseTime, throughput, networkV2, minResponseTime, maxResponseTime, percentile90, | ||
percentile95, percentile99, statusCodes, errorRate, | ||
} = plot; | ||
|
||
const threadLine = { ...threadLineSettings, name: "virtual users", data: threads, tooltip: { valueSuffix: "" } }; | ||
const errorLine = { ...errorLineSettings, ...overAllFailRate, tooltip: { valueSuffix: " %" } }; | ||
const throughputLine = { ...throughputLineSettings, ...overallThroughput, tooltip: { valueSuffix: " reqs/s" } }; | ||
|
||
const chartLines = { | ||
overall: new Map(), | ||
labels: new Map(), | ||
statusCodes: new Map() | ||
}; | ||
|
||
if (overAllNetworkV2) { | ||
const networkMbps = overAllNetworkV2.data.map((_) => { | ||
return [_[0], bytesToMbps(_[1])]; | ||
}); | ||
const networkLine = { ...networkLineSettings, data: networkMbps, tooltip: { valueSuffix: " mbps" } }; | ||
chartLines.overall.set(Metrics.Network, networkLine); | ||
} | ||
|
||
// not all reports have status code plot data | ||
if (statusCodes) { | ||
chartLines.statusCodes.set(Metrics.StatusCodeInTime, { data: statusCodes }); | ||
} | ||
|
||
chartLines.overall.set(Metrics.ResponseTimeAvg, { ...overallTimeResponse, tooltip: { valueSuffix: " ms" } }); | ||
chartLines.overall.set(Metrics.Threads, threadLine); | ||
chartLines.overall.set(Metrics.ErrorRate, errorLine); | ||
chartLines.overall.set(Metrics.Throughput, throughputLine); | ||
|
||
if (networkV2) { | ||
const networkMbps = networkV2.map((_) => { | ||
_.data = _.data.map(__ => [__[0], bytesToMbps(__[1])]); | ||
return _; | ||
}); | ||
|
||
chartLines.labels.set(Metrics.Network, networkMbps.map((label) => ({ ...label, suffix: " mbps" }))); | ||
} | ||
|
||
if (minResponseTime) { | ||
chartLines.labels.set(Metrics.ResponseTimeMin, minResponseTime.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
|
||
if (maxResponseTime) { | ||
chartLines.labels.set(Metrics.ResponseTimeMax, maxResponseTime.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
if (percentile90) { | ||
chartLines.labels.set(Metrics.ResponseTimeP90, percentile90.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
if (percentile95) { | ||
chartLines.labels.set(Metrics.ResponseTimeP95, percentile95.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
if (percentile99) { | ||
chartLines.labels.set(Metrics.ResponseTimeP99, percentile99.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
if (errorRate) { | ||
chartLines.labels.set(Metrics.ErrorRate, errorRate.map((label) => ({ ...label, suffix: " %" }))); | ||
} | ||
chartLines.labels.set(Metrics.ResponseTimeAvg, responseTime.map((label) => ({ ...label, suffix: " ms" }))); | ||
chartLines.labels.set(Metrics.Throughput, throughput.map((label) => ({ ...label, suffix: " reqs/s" }))); | ||
|
||
return { chartLines }; | ||
|
||
}; | ||
|
||
|
||
export interface ChartLines { | ||
chartLines: ChartLine; | ||
} | ||
|
||
export interface ChartLine { | ||
labels: Map<string, LabelChartLine[]>; | ||
overall: Map<string, { name: string, data: [] }>; | ||
} | ||
|
||
export interface LabelChartLine { | ||
name: string | ||
data: [], | ||
suffix: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from "@angular/core/testing"; | ||
|
||
import { ComparisonChartService } from "./comparison-chart.service"; | ||
|
||
describe("ComparisonChartService", () => { | ||
let service: ComparisonChartService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(ComparisonChartService); | ||
}); | ||
|
||
it("should be created", () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { BehaviorSubject } from "rxjs"; | ||
import { ChartLines, getChartLines } from "./chart-service-utils"; | ||
|
||
@Injectable({ | ||
providedIn: "root" | ||
}) | ||
export class ComparisonChartService { | ||
|
||
|
||
private plot$ = new BehaviorSubject<ChartLines>({ chartLines: null }); | ||
private histogramPlot$ = new BehaviorSubject<{ responseTimePerLabelDistribution: []}>(null); | ||
|
||
private interval$ = new BehaviorSubject<string>(null); | ||
selectedPlot$ = this.plot$.asObservable(); | ||
histogram$ = this.histogramPlot$.asObservable() | ||
|
||
|
||
setInterval(interval) { | ||
this.interval$.next(interval); | ||
} | ||
|
||
setHistogramPlot(plot) { | ||
this.histogramPlot$.next(plot); | ||
} | ||
|
||
resetPlot() { | ||
this.plot$.next(null) | ||
|
||
} | ||
|
||
setComparisonPlot(defaultPlot, extraPlots) { | ||
this.interval$.subscribe(interval => { | ||
let comparisonPlot = null | ||
if (!interval || interval === "Auto") { | ||
comparisonPlot = defaultPlot | ||
} else { | ||
const extraPlotIntervalData = extraPlots?.find(extraPlot => extraPlot.interval === interval)?.data | ||
comparisonPlot = extraPlotIntervalData || defaultPlot | ||
} | ||
this.plot$.next(comparisonPlot ? getChartLines(comparisonPlot): null) | ||
}) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,23 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { BehaviorSubject } from "rxjs"; | ||
import { errorLineSettings, networkLineSettings, threadLineSettings, throughputLineSettings } from "../graphs/item-detail"; | ||
import { bytesToMbps } from "../item-detail/calculations"; | ||
import { Metrics } from "../item-detail/metrics"; | ||
import { ChartLines, getChartLines } from "./chart-service-utils"; | ||
|
||
@Injectable({ | ||
providedIn: "root" | ||
}) | ||
export class ItemChartService { | ||
|
||
private plot$ = new BehaviorSubject<ChartLines>({ chartLines: null }); | ||
selectedPlot$ = this.plot$.asObservable(); | ||
|
||
setCurrentPlot(plot) { | ||
this.plot$.next(this.getChartLines(plot)); | ||
} | ||
|
||
|
||
private getChartLines(plot): ChartLines { | ||
const { | ||
threads, overallTimeResponse, | ||
overallThroughput, overAllFailRate, overAllNetworkV2, | ||
responseTime, throughput, networkV2, minResponseTime, maxResponseTime, percentile90, | ||
percentile95, percentile99, statusCodes, errorRate, | ||
} = plot; | ||
|
||
const threadLine = { ...threadLineSettings, name: "virtual users", data: threads, tooltip: { valueSuffix: "" } }; | ||
const errorLine = { ...errorLineSettings, ...overAllFailRate, tooltip: { valueSuffix: " %" } }; | ||
const throughputLine = { ...throughputLineSettings, ...overallThroughput, tooltip: { valueSuffix: " reqs/s" } }; | ||
|
||
const chartLines = { | ||
overall: new Map(), | ||
labels: new Map(), | ||
statusCodes: new Map() | ||
} | ||
|
||
if (overAllNetworkV2) { | ||
const networkMbps = overAllNetworkV2.data.map((_) => { | ||
return [_[0], bytesToMbps(_[1])]; | ||
}); | ||
const networkLine = { ...networkLineSettings, data: networkMbps, tooltip: { valueSuffix: " mbps" } }; | ||
chartLines.overall.set(Metrics.Network, networkLine); | ||
} | ||
|
||
// not all reports have status code plot data | ||
if (statusCodes) { | ||
chartLines.statusCodes.set(Metrics.StatusCodeInTime, { data: statusCodes }) | ||
} | ||
|
||
chartLines.overall.set(Metrics.ResponseTimeAvg, { ...overallTimeResponse, tooltip: { valueSuffix: " ms" } }); | ||
chartLines.overall.set(Metrics.Threads, threadLine); | ||
chartLines.overall.set(Metrics.ErrorRate, errorLine); | ||
chartLines.overall.set(Metrics.Throughput, throughputLine); | ||
|
||
if (networkV2) { | ||
const networkMbps = networkV2.map((_) => { | ||
_.data = _.data.map(__ => [__[0], bytesToMbps(__[1])]); | ||
return _; | ||
}); | ||
|
||
chartLines.labels.set(Metrics.Network, networkMbps.map((label) => ({ ...label, suffix: " mbps" }))); | ||
} | ||
private interval; | ||
|
||
if (minResponseTime) { | ||
chartLines.labels.set(Metrics.ResponseTimeMin, minResponseTime.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
|
||
if (maxResponseTime) { | ||
chartLines.labels.set(Metrics.ResponseTimeMax, maxResponseTime.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
if (percentile90) { | ||
chartLines.labels.set(Metrics.ResponseTimeP90, percentile90.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
if (percentile95) { | ||
chartLines.labels.set(Metrics.ResponseTimeP95, percentile95.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
if (percentile99) { | ||
chartLines.labels.set(Metrics.ResponseTimeP99, percentile99.map((label) => ({ ...label, suffix: " ms" }))); | ||
} | ||
if (errorRate) { | ||
chartLines.labels.set(Metrics.ErrorRate, errorRate.map((label) => ({ ...label, suffix: " %" }))) | ||
} | ||
chartLines.labels.set(Metrics.ResponseTimeAvg, responseTime.map((label) => ({ ...label, suffix: " ms" }))); | ||
chartLines.labels.set(Metrics.Throughput, throughput.map((label) => ({ ...label, suffix: " reqs/s" }))); | ||
selectedPlot$ = this.plot$.asObservable(); | ||
|
||
return { chartLines } | ||
|
||
setInterval(interval) { | ||
this.interval = interval; | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
interface ChartLines { | ||
chartLines: ChartLine | ||
} | ||
|
||
export interface ChartLine { | ||
labels: Map<string, LabelChartLine[]> | ||
overall: Map<string, { name: string, data: [] }> | ||
} | ||
|
||
export interface LabelChartLine { | ||
name: string | ||
data: [], | ||
suffix: string | ||
setCurrentPlot(plot) { | ||
this.plot$.next(getChartLines(plot)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.