Skip to content

Commit e8f71f3

Browse files
committed
feat: sort charts
1 parent 02c7a72 commit e8f71f3

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

report/src/components/ChartGrid.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { CHART_CONFIG } from "../metricDefinitions";
2+
import { SORTED_CHART_CONFIG } from "../metricDefinitions";
33
import { DataSeries } from "../types";
44
import LineChart from "./LineChart";
55

@@ -11,9 +11,8 @@ interface ProvidedProps {
1111
const ChartGrid: React.FC<ProvidedProps> = ({ data, role }: ProvidedProps) => {
1212
return (
1313
<div className="charts-container">
14-
{Object.entries(CHART_CONFIG).map(([metricKey, config]) => {
14+
{SORTED_CHART_CONFIG.map(([metricKey, config]) => {
1515
// sequencer and validator have different thresholds
16-
console.log(role, metricKey);
1716
const thresholdKey = role ? `${role}/${metricKey}` : null;
1817
const chartData = data.flatMap((s) => s.data);
1918
const thresholds = data[0]?.thresholds;

report/src/metricDefinitions.ts

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChartConfig } from "./types"; // Import from types.ts
2-
export const CHART_CONFIG: Record<string, ChartConfig> = {
2+
export const CHART_CONFIG = {
33
"latency/send_txs": {
44
type: "line",
55
title: "Send Txs",
@@ -210,4 +210,46 @@ export const CHART_CONFIG: Record<string, ChartConfig> = {
210210
description: "Shows the 90th percentile latency for account loads",
211211
unit: "s",
212212
},
213-
};
213+
} satisfies Record<string, ChartConfig>;
214+
215+
const CHART_CONFIG_ORDER: (keyof typeof CHART_CONFIG)[] = [
216+
"latency/get_payload",
217+
"latency/new_payload",
218+
"latency/update_fork_choice",
219+
"latency/send_txs",
220+
"gas/per_block",
221+
"transactions/per_block",
222+
"chain/inserts.50-percentile",
223+
"chain/account/reads.50-percentile",
224+
"chain/storage/reads.50-percentile",
225+
"chain/execution.50-percentile",
226+
"chain/account/updates.50-percentile",
227+
"chain/account/hashes.50-percentile",
228+
"chain/storage/updates.50-percentile",
229+
"chain/validation.50-percentile",
230+
"chain/crossvalidation.50-percentile",
231+
"chain/write.50-percentile",
232+
"chain/account/commits.50-percentile",
233+
"chain/storage/commits.50-percentile",
234+
"chain/snapshot/commits.50-percentile",
235+
"chain/triedb/commits.50-percentile",
236+
];
237+
238+
export const SORTED_CHART_CONFIG: [string, ChartConfig][] = Object.entries(
239+
CHART_CONFIG,
240+
).sort((a, b) => {
241+
const aIndex = CHART_CONFIG_ORDER.indexOf(a[0] as keyof typeof CHART_CONFIG);
242+
const bIndex = CHART_CONFIG_ORDER.indexOf(b[0] as keyof typeof CHART_CONFIG);
243+
244+
// if both doesn't exist, sort it last (infinity)
245+
if (aIndex === -1 && bIndex === -1) {
246+
return 0;
247+
}
248+
if (aIndex === -1) {
249+
return 1;
250+
}
251+
if (bIndex === -1) {
252+
return -1;
253+
}
254+
return aIndex - bIndex;
255+
});

0 commit comments

Comments
 (0)