Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Add the new columns for throughput metrics #125

Merged
merged 10 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions portal/mock-server/src/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
"iterations": 1000,
"message_size": 1024,
"results": {
"averageCPU": 3.5,
"averageMemory": 3
"average_cpu": 3.5,
"average_memory": 3,
"bytes_throughput": 11,
"request_throughput": 21
}
},
{
Expand All @@ -31,8 +33,10 @@
"iterations": 2000,
"message_size": 2048,
"results": {
"averageCPU": 7.0,
"averageMemory": 6
"average_cpu": 7.0,
"average_memory": 6,
"bytes_throughput": 12,
"request_throughput": 24
}
},
{
Expand All @@ -41,8 +45,10 @@
"iterations": 1000,
"message_size": 1024,
"results": {
"averageCPU": 1.7,
"averageMemory": 2
"average_cpu": 1.7,
"average_memory": 2,
"bytes_throughput": 20,
"request_throughput": 30
}
},
{
Expand All @@ -51,8 +57,10 @@
"iterations": 2000,
"message_size": 1024,
"results": {
"averageCPU": 2.6,
"averageMemory": 2
"average_cpu": 2.6,
"average_memory": 2,
"bytes_throughput": 10,
"request_throughput": 20
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion portal/src/app/apis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const testSuites = 'test_suites';

export const APIS: { [key in keyof typeof API_URLS]: string } = {
analyze: 'analyze',
algorithms: 'algorithms',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,46 @@ const data = [
"algorithm": "Algorithm1",
"iterations": 1,
"results": {
"averageCPU": 5,
"averageMemory": 512,
"average_cpu": 5,
"average_memory": 512,
}
},
{
"algorithm": "Algorithm1",
"iterations": 133,
"results": {
"averageCPU": 533,
"averageMemory": 512,
"average_cpu": 533,
"average_memory": 512,
}
},
{
"algorithm": "Algorithm1",
"iterations": 1000,
"results": {
"averageCPU": 25,
"averageMemory": 512,
"average_cpu": 25,
"average_memory": 512,
}
},
{
"algorithm": "Algorithm2",
"iterations": 2000,
"results": {
"averageCPU": 28,
"averageMemory": 512,
"average_cpu": 28,
"average_memory": 512,
}
},
{
"algorithm": "Algorithm3",
"iterations": 2000,
"results": {
"averageCPU": 28,
"averageMemory": 512,
"average_cpu": 28,
"average_memory": 512,
}
}
];
describe('BarChart', () => {
test('renders BarChart component', () => {
const { getByTestId }: RenderResult = render(<BarChart labels={['Algorithm1', 'Algorithm1']} data={data} title={'chart'} keyOfData={'averageCPU'} tooltipKeys={tooltipKeys} tooltipLabels={tooltipLabels} />);
const { getByTestId }: RenderResult = render(<BarChart labels={['Algorithm1', 'Algorithm1']} data={data} title={'chart'} keyOfData={'average_cpu'} tooltipKeys={tooltipKeys} tooltipLabels={tooltipLabels} />);
const chartElement: HTMLElement = getByTestId('chart');
expect(chartElement).toBeTruthy();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mockData = {

describe('LineChart', () => {
test('renders LineChart', () => {
const { getByTestId }: RenderResult = render(<LineChart data={mockData} title='title' tooltipLabel='averageCPU' />);
const { getByTestId }: RenderResult = render(<LineChart data={mockData} title='title' tooltipLabel='average_cpu' />);
const chartElement: HTMLElement = getByTestId('line2');
expect(chartElement).toBeTruthy();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ export const MOCK_DATA_FOR_EXPERIMENT: ITestRunResult = {
message_size: 1024,
results:
{
averageCPU: 25.5,
averageMemory: 512,
average_cpu: 25.5,
average_memory: 512,
bytes_throughput: 11,
request_throughput: 21
}
},
{
Expand All @@ -36,8 +38,10 @@ export const MOCK_DATA_FOR_EXPERIMENT: ITestRunResult = {
message_size: 1024,
results:
{
averageCPU: 25.5,
averageMemory: 512,
average_cpu: 25.5,
average_memory: 512,
bytes_throughput: 11,
request_throughput: 21
}
},
{
Expand All @@ -47,8 +51,10 @@ export const MOCK_DATA_FOR_EXPERIMENT: ITestRunResult = {
message_size: 1024,
results:
{
averageCPU: 2,
averageMemory: 52,
average_cpu: 2,
average_memory: 52,
bytes_throughput: 11,
request_throughput: 21
}
}
]
Expand Down Expand Up @@ -79,8 +85,10 @@ export const MOCK_DATA_FOR_EXPERIMENT_TABLE: ExperimentTableProps = {
message_size: 1024,
results:
{
averageCPU: 25.5,
averageMemory: 512,
average_cpu: 25.5,
average_memory: 512,
bytes_throughput: 11,
request_throughput: 21
}
},
{
Expand All @@ -90,8 +98,10 @@ export const MOCK_DATA_FOR_EXPERIMENT_TABLE: ExperimentTableProps = {
message_size: 512,
results:
{
averageCPU: 25.5,
averageMemory: 512,
average_cpu: 25.5,
average_memory: 512,
bytes_throughput: 11,
request_throughput: 21
}
},
{
Expand All @@ -101,8 +111,10 @@ export const MOCK_DATA_FOR_EXPERIMENT_TABLE: ExperimentTableProps = {
message_size: 2048,
results:
{
averageCPU: 2,
averageMemory: 52,
average_cpu: 2,
average_memory: 52,
bytes_throughput: 11,
request_throughput: 21
}
}
]
Expand All @@ -118,11 +130,11 @@ export const MOCK_DATA_FOR_EXPERIMENT_TABLE: ExperimentTableProps = {
},
{
label: "Average CPU",
value: "averageCPU",
value: "average_cpu",
},
{
label: "Average Memory",
value: "averageMemory",
value: "average_memory",
},
]
};
Expand Down Expand Up @@ -157,11 +169,11 @@ export const MOCK_DATA_FOR_EXPERIMENT_WITH_NO_TEST_RUNS: ExperimentTableProps =
},
{
label: "Average CPU",
value: "averageCPU",
value: "average_cpu",
},
{
label: "Average Memory",
value: "averageMemory",
value: "average_memory",
},
]
};
Expand Down Expand Up @@ -189,8 +201,10 @@ export const MOCK_SUB_HEADER: ITestRunResult = {
iterations: 1000,
message_size: 1024,
results: {
averageCPU: 3.5,
averageMemory: 3
average_cpu: 3.5,
average_memory: 3,
bytes_throughput: 11,
request_throughput: 21
}
},
],
Expand All @@ -203,8 +217,10 @@ export const CSV_MOCK: ITestRunResultData[] = [
iterations: 1000,
message_size: 1024,
results: {
averageCPU: 2000,
averageMemory: 3000,
average_cpu: 2000,
average_memory: 3000,
bytes_throughput: 11,
request_throughput: 21
},
},
{
Expand All @@ -213,8 +229,10 @@ export const CSV_MOCK: ITestRunResultData[] = [
iterations: 4000,
message_size: 2048,
results: {
averageCPU: 5000,
averageMemory: 6000,
average_cpu: 5000,
average_memory: 6000,
bytes_throughput: 11,
request_throughput: 21
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ export const MOCK_DATA_FOR_CHARTS: IExperimentData = {
message_size: 1024,
results:
{
averageCPU: 25.5,
averageMemory: 512,
average_cpu: 25.5,
average_memory: 512,
bytes_throughput: 11,
request_throughput: 21
}
},
{
Expand All @@ -36,8 +38,10 @@ export const MOCK_DATA_FOR_CHARTS: IExperimentData = {
message_size: 512,
results:
{
averageCPU: 25.5,
averageMemory: 512,
average_cpu: 25.5,
average_memory: 512,
bytes_throughput: 11,
request_throughput: 21
}
},
{
Expand All @@ -47,8 +51,10 @@ export const MOCK_DATA_FOR_CHARTS: IExperimentData = {
message_size: 1024,
results:
{
averageCPU: 2,
averageMemory: 52,
average_cpu: 2,
average_memory: 52,
bytes_throughput: 11,
request_throughput: 21
}
}
]
Expand All @@ -59,13 +65,13 @@ export const MOCK_DATA_FOR_BAR_CHART = [{
algorithm: "Algorithm1",
iterations: 100,
results: {
averageCPU: 2,
averageMemory: 52,
average_cpu: 2,
average_memory: 52,
},
}];

export const MOCK_DATA_FOR_BAR_CHART_LABELS = ['Algorithm1'];
export const MOCK_DATA_FOR_BAR_CHART_KEYS = ["averageCPU", "averageMemory", "errorRate", "bytesThroughput", "messagesThroughput", "averageTLSHandshakeTime"];
export const MOCK_DATA_FOR_BAR_CHART_KEYS = ["average_cpu", "average_memory", "errorRate", "bytesThroughput", "messagesThroughput", "averageTLSHandshakeTime"];
export const MOCK_DATA_FOR_LINE_CHART = {
datasets: [{
backgroundColor: "#05BBFF",
Expand All @@ -74,8 +80,8 @@ export const MOCK_DATA_FOR_LINE_CHART = {
fill: false,
label: "Algorithm1",
data: {
averageCPU: [2],
averageMemory: [3],
average_cpu: [2],
average_memory: [3],
}
}],
labels: [24, 104, 122, 124, 1024],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('useDynamicChartData', () => {

const { result } = renderHook(() => useDynamicChartData(MOCK_DATA_FOR_EXPERIMENT));
act(() => {
expect(result.current).toEqual( {yAxiosOptions: [{label: "Average CPU", value: "averageCPU"}, {label: "Average Memory", value: "averageMemory"}]});
expect(result.current).toEqual( {yAxiosOptions: [{label: "Average Cpu", value: "average_cpu"}, {label: "Average Memory", value: "average_memory"}, {label: "Bytes Throughput", value: "bytes_throughput"}, {label: "Request Throughput", value: "request_throughput"}]});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ export function useDynamicChartData(chartData: ITestRunResult): IUseDynamicChart
}

function convertLabelByCapitalLetter(str: string): string {
let isFirstCapital = true;
const result = str.replace(/([A-Z])/g, (match) => {
if (isFirstCapital) {
isFirstCapital = false;
return ` ${match}`;
}
return match;
}).trim();
return result.charAt(0).toUpperCase() + result.slice(1);
return str
.split('_') // split the string by underscore
.map(word => word.charAt(0).toUpperCase() + word.slice(1)) // capitalize the first letter of each word
.join(' '); // join the words back together with a space
}
Loading
Loading