|
1 | 1 | import { ChartConfig } from "./types"; // Import from types.ts |
2 | | -export const CHART_CONFIG: Record<string, ChartConfig> = { |
| 2 | +export const CHART_CONFIG = { |
3 | 3 | "latency/send_txs": { |
4 | 4 | type: "line", |
5 | 5 | title: "Send Txs", |
@@ -210,4 +210,46 @@ export const CHART_CONFIG: Record<string, ChartConfig> = { |
210 | 210 | description: "Shows the 90th percentile latency for account loads", |
211 | 211 | unit: "s", |
212 | 212 | }, |
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