Skip to content

Commit c1a761f

Browse files
committed
Merge branch 'nakrovati-improve-design'
2 parents 982e689 + 5ab8d22 commit c1a761f

20 files changed

+238
-234
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default [
2626
"unicorn/prefer-ternary": "off",
2727
"unicorn/require-number-to-fixed-digits-argument": "off",
2828
"unicorn/prefer-set-has": "off",
29-
"unicorn/unicorn/no-array-reduce": "off",
29+
"unicorn/no-array-reduce": "off",
3030
// maybe not:
3131
"unicorn/consistent-function-scoping": "off",
3232
"unicorn/no-array-for-each": "off",

push_results.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
cp webdriver-ts-results/dist/index.html ../krausest.github.io/js-framework-benchmark/current.html
22
cp webdriver-ts-results/dist/BoxPlotTable*.js ../krausest.github.io/js-framework-benchmark/
3-
cp webdriver-ts-results/dist/plotly*.js ../krausest.github.io/js-framework-benchmark/
3+
cp webdriver-ts-results/dist/chartjs*.js ../krausest.github.io/js-framework-benchmark/
44
cp webdriver-ts-results/dist/index*.css ../krausest.github.io/js-framework-benchmark/
55
cp webdriver-ts-results/dist/index*.js ../krausest.github.io/js-framework-benchmark/
66
cd ../krausest.github.io
77
git add js-framework-benchmark/current.html
88
git add js-framework-benchmark/BoxPlotTable*.js
9-
git add js-framework-benchmark/plotly*.js
9+
git add js-framework-benchmark/chartjs*.js
1010
git add js-framework-benchmark/index*.css
1111
git add js-framework-benchmark/index*.js
1212
git commit -m "update results"

webdriver-ts-results/package-lock.json

Lines changed: 34 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webdriver-ts-results/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"private": true,
55
"type": "module",
66
"dependencies": {
7+
"@sgratzl/chartjs-chart-boxplot": "^4.2.8",
78
"antd": "^5.14.2",
9+
"chart.js": "^4.4.2",
810
"jstat": "^1.9.6",
911
"lucide-react": "^0.344.0",
10-
"plotly.js-cartesian-dist": "2.18.2",
1112
"react": "^18.2.0",
1213
"react-dom": "^18.2.0",
1314
"zustand": "^4.4.1"

webdriver-ts-results/src/Common.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export class TableResultValueEntry {
171171
public bgColor: string,
172172
public textColor: string,
173173
public statisticResult: StatisticResult,
174+
// eslint-disable-next-line unicorn/no-useless-undefined
174175
public statisticallySignificantFactor: string | number | undefined = undefined
175176
) {}
176177
}
@@ -331,6 +332,7 @@ export class ResultTableData {
331332
sortBy(sortKey: string): void {
332333
const zipped = this.frameworks.map((f, frameworkIndex) => {
333334
let sortValue;
335+
// eslint-disable-next-line unicorn/prefer-switch
334336
if (sortKey === SORT_BY_NAME) sortValue = f.name;
335337
else if (sortKey === SORT_BY_GEOMMEAN_CPU)
336338
sortValue = this.getResult(BenchmarkType.CPU).geomMean[frameworkIndex]!.mean || Number.POSITIVE_INFINITY;
@@ -358,7 +360,7 @@ export class ResultTableData {
358360
else if (sizeIdx > -1)
359361
sortValue =
360362
this.getResult(BenchmarkType.SIZE).results[sizeIdx][frameworkIndex]?.value ?? Number.POSITIVE_INFINITY;
361-
else throw Error(`sortKey ${sortKey} not found`);
363+
else throw new Error(`sortKey ${sortKey} not found`);
362364
}
363365
return {
364366
framework: f,
@@ -396,12 +398,12 @@ export class ResultTableData {
396398
0.5277091212292658, 0.5644449600965534, 0.5508359820582848, 0.4225836631419211,
397399
];
398400
} else {
399-
benchmarkWeights = new Array(benchmarks.length).fill(1);
401+
benchmarkWeights = Array.from<number>({ length: benchmarks.length }).fill(1);
400402
}
401403

402404
let gMean = 0.0;
403405
resultsForFramework.forEach((r, idx) => {
404-
if (r !== null && !isNaN(r.factor)) {
406+
if (r !== null && !Number.isNaN(r.factor)) {
405407
gMean += benchmarkWeights[idx] * Math.log(r.factor);
406408
}
407409
});
@@ -460,6 +462,7 @@ export class ResultTableData {
460462
return result.results[resultsKey].mean;
461463
}
462464
};
465+
463466
const min = Math.max(
464467
benchmarkResults.reduce(
465468
(min, result) => (result === null ? min : Math.min(min, selectFn(result))),
@@ -504,8 +507,8 @@ export class ResultTableData {
504507

505508
// X1,..,Xn: this Framework, Y1, ..., Ym: selected Framework
506509
// https://de.wikipedia.org/wiki/Zweistichproben-t-Test
507-
let statisticalResult = undefined;
508-
let statisticalCol = undefined;
510+
let statisticalResult;
511+
let statisticalCol;
509512
const compareWithMean = compareWithResultsValues.mean;
510513
const stdDev = resultValues.standardDeviation || 0;
511514
const compareWithResultsStdDev = compareWithResultsValues.standardDeviation || 0;

webdriver-ts-results/src/components/BoxPlotTable/BoxPlotTable.tsx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import React from "react";
2-
import {
3-
SORT_BY_NAME,
4-
Benchmark,
5-
Framework,
6-
ResultLookup,
7-
CpuDurationMode,
8-
} from "@/Common";
2+
import { SORT_BY_NAME, Benchmark, Framework, ResultLookup, CpuDurationMode } from "@/Common";
93
import BoxPlotTableRows from "./BoxPlotTableRows";
104

115
interface Props {
@@ -17,14 +11,7 @@ interface Props {
1711
cpuDurationMode: CpuDurationMode;
1812
}
1913

20-
const BoxPlotTable = ({
21-
frameworks,
22-
benchmarks,
23-
results,
24-
currentSortKey,
25-
sortBy,
26-
cpuDurationMode,
27-
}: Props) => {
14+
const BoxPlotTable = ({ frameworks, benchmarks, results, currentSortKey, sortBy, cpuDurationMode }: Props) => {
2815
const handleSortByName = (event: React.MouseEvent) => {
2916
event.preventDefault();
3017
sortBy(SORT_BY_NAME);
@@ -39,9 +26,7 @@ const BoxPlotTable = ({
3926
<tr>
4027
<th className="benchname">
4128
<button
42-
className={`button button__text ${
43-
currentSortKey === SORT_BY_NAME ? "sort-key" : ""
44-
}`}
29+
className={`button button__text ${currentSortKey === SORT_BY_NAME ? "sort-key" : ""}`}
4530
aria-label="Sort frameworks in ascending order (asc)"
4631
onClick={handleSortByName}
4732
>
Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import { useRef, useEffect } from "react";
2-
import Plotly from "plotly.js-cartesian-dist";
2+
import { BoxPlotChart } from "@sgratzl/chartjs-chart-boxplot";
3+
import { Chart, ChartConfiguration } from "chart.js";
4+
5+
Chart.register(BoxPlotChart);
6+
7+
const backgroundColor = [
8+
"hsl(0 80% 50%)", // Red
9+
"hsl(40 80% 50%)", // Orange
10+
"hsl(80 80% 50%)", // Yellow
11+
"hsl(120 80% 50%)", // Green
12+
"hsl(160 80% 50%)", // Cyan
13+
"hsl(200 80% 50%)", // Blue
14+
"hsl(240 80% 50%)", // Purple
15+
"hsl(280 80% 50%)", // Magenta
16+
"hsl(320 80% 50%)", // Pink
17+
];
318

419
interface BoxPlotData {
520
framework: string;
@@ -11,34 +26,57 @@ interface Props {
1126
}
1227

1328
const BoxPlotTableChart = ({ traces }: Props) => {
14-
const elemRef = useRef(null);
29+
const chartRef = useRef<HTMLCanvasElement>(null);
1530

1631
useEffect(() => {
17-
const plotlTtraces = traces.map((t) => ({
18-
type: "box",
19-
y: t.values,
20-
boxpoints: false,
21-
jitter: 0.5,
22-
name: t.framework,
23-
boxmean: "sd",
24-
}));
25-
26-
const layout = {
27-
showlegend: false,
28-
margin: {
29-
l: 40,
30-
r: 0,
31-
b: 120,
32-
t: 0,
33-
pad: 0,
32+
const labels: string[] = [];
33+
const data: number[][] = [];
34+
35+
for (const trace of traces) {
36+
labels.push(trace.framework);
37+
data.push(trace.values);
38+
}
39+
40+
const config: ChartConfiguration<"boxplot"> = {
41+
type: "boxplot",
42+
data: {
43+
labels,
44+
datasets: [
45+
{
46+
backgroundColor,
47+
data,
48+
},
49+
],
50+
},
51+
options: {
52+
animation: false,
53+
scales: {
54+
x: {
55+
type: "category",
56+
grid: {
57+
display: false,
58+
},
59+
},
60+
y: {
61+
type: "linear",
62+
beginAtZero: false,
63+
},
64+
},
3465
},
3566
};
36-
Plotly.newPlot(elemRef.current, plotlTtraces, layout, {
37-
staticPlot: true,
38-
editable: false,
39-
});
67+
68+
const chart = new BoxPlotChart(chartRef.current!, config);
69+
70+
return () => {
71+
chart.destroy();
72+
};
4073
}, [traces]);
41-
return <div ref={elemRef} style={{ height: "100%", width: "100%" }}></div>;
74+
75+
return (
76+
<div style={{ height: "28rem" }}>
77+
<canvas style={{ maxHeight: "100%" }} ref={chartRef}></canvas>
78+
</div>
79+
);
4280
};
4381

4482
export default BoxPlotTableChart;

webdriver-ts-results/src/components/BoxPlotTable/BoxPlotTableRow.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,8 @@ interface Props {
1111
cpuDurationMode: CpuDurationMode;
1212
}
1313

14-
const BoxPlotTableRow = ({
15-
frameworks,
16-
benchmark,
17-
results,
18-
currentSortKey,
19-
sortBy,
20-
cpuDurationMode,
21-
}: Props) => {
22-
const resultsValues = (framework: Framework) =>
23-
results(benchmark, framework)?.results[cpuDurationMode].values ?? [];
14+
const BoxPlotTableRow = ({ frameworks, benchmark, results, currentSortKey, sortBy, cpuDurationMode }: Props) => {
15+
const resultsValues = (framework: Framework) => results(benchmark, framework)?.results[cpuDurationMode].values ?? [];
2416

2517
const handleSortByBenchmarkResults = (event: React.MouseEvent) => {
2618
event.preventDefault();
@@ -36,9 +28,7 @@ const BoxPlotTableRow = ({
3628
<tr key={benchmark.id} style={{ height: 400 }}>
3729
<th className="benchname">
3830
<button
39-
className={`button button__text ${
40-
currentSortKey === benchmark.id ? "sort-key" : ""
41-
}`}
31+
className={`button button__text ${currentSortKey === benchmark.id ? "sort-key" : ""}`}
4232
onClick={handleSortByBenchmarkResults}
4333
aria-label="Sort by benchmark results (from best to worst)"
4434
>

webdriver-ts-results/src/components/BoxPlotTable/BoxPlotTableRows.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ interface Props {
1010
cpuDurationMode: CpuDurationMode;
1111
}
1212

13-
const BoxPlotTableRows = ({
14-
frameworks,
15-
benchmarks,
16-
results,
17-
currentSortKey,
18-
sortBy,
19-
cpuDurationMode,
20-
}: Props) => {
13+
const BoxPlotTableRows = ({ frameworks, benchmarks, results, currentSortKey, sortBy, cpuDurationMode }: Props) => {
2114
return (
2215
<>
2316
{benchmarks.map((benchmark) => (

webdriver-ts-results/src/components/ResultTable/ResultTable.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { benchmarks } from "@/results";
77
import { useRootStore } from "@/reducer";
88
import SizeResultsTable from "@/components/tables/SizeResultsTable";
99

10-
const BoxPlotTable = React.lazy(() => import("@/components/BoxPlotTable"));
10+
const BoxPlotTable = React.lazy(() => import("@/components/BoxPlotTable/BoxPlotTable"));
1111

1212
interface Props {
1313
type: FrameworkType;
@@ -37,10 +37,10 @@ const ResultTable = ({ type }: Props) => {
3737

3838
if (
3939
!data ||
40-
!data.frameworks.length ||
41-
(!data.getResult(BenchmarkType.CPU).benchmarks.length &&
42-
!data.getResult(BenchmarkType.STARTUP).benchmarks.length &&
43-
!data.getResult(BenchmarkType.MEM).benchmarks.length)
40+
data.frameworks.length === 0 ||
41+
(data.getResult(BenchmarkType.CPU).benchmarks.length === 0 &&
42+
data.getResult(BenchmarkType.STARTUP).benchmarks.length === 0 &&
43+
data.getResult(BenchmarkType.MEM).benchmarks.length === 0)
4444
) {
4545
return null;
4646
}
@@ -66,7 +66,7 @@ const ResultTable = ({ type }: Props) => {
6666
</h3>
6767
)}
6868
{displayMode === DisplayMode.BoxPlot ? (
69-
benchmarks.length && (
69+
benchmarks.length > 0 && (
7070
<React.Suspense fallback={<div>Loading...</div>}>
7171
<BoxPlotTable
7272
results={data.results}

0 commit comments

Comments
 (0)