Skip to content

Commit 2668204

Browse files
authored
Add blocks to ui (#177)
1 parent a371c25 commit 2668204

4 files changed

Lines changed: 49 additions & 5 deletions

File tree

report/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Base Bench Metrics</title>
6+
<title>Base Load Tests</title>
77
</head>
88
<body>
99
<div id="root"></div>

report/src/pages/LoadTestDetail.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {
1212
durationToNanos,
1313
formatDuration,
1414
formatEthFromWei,
15-
formatGps,
15+
formatGasVerbose,
16+
formatGpsVerbose,
1617
formatLoadTestTimestamp,
1718
formatPercent,
1819
formatTps,
19-
formatValue,
2020
} from "../utils/formatters";
2121
import {
2222
FlashblocksLatencyStats,
@@ -107,17 +107,27 @@ const SummarySection = ({ result }: { result: LoadTestResult }) => {
107107
/>
108108
<Stat label="Failed" value={failed.toLocaleString()} />
109109
<Stat label="Avg TPS" value={formatTps(result.throughput.tps)} />
110-
<Stat label="Avg gas/s" value={formatGps(result.throughput.gps)} />
110+
<Stat
111+
label="Avg gas/s"
112+
value={formatGpsVerbose(result.throughput.gps)}
113+
/>
111114
<Stat
112115
label="Total gas"
113-
value={formatValue(result.gas.total_gas, "gas")}
116+
value={formatGasVerbose(result.gas.total_gas)}
114117
hint={`${result.gas.avg_gas.toLocaleString()} avg / tx`}
115118
/>
116119
<Stat
117120
label="Total cost"
118121
value={formatEthFromWei(result.gas.total_cost_wei)}
119122
hint={`${result.gas.avg_gas_price.toLocaleString()} wei avg gas price`}
120123
/>
124+
{result.block_range && (
125+
<Stat
126+
label="Block range"
127+
value={`${result.block_range.first_block.toLocaleString()}${result.block_range.last_block.toLocaleString()}`}
128+
hint={`${result.block_range.block_count.toLocaleString()} blocks`}
129+
/>
130+
)}
121131
</StatGrid>
122132
</StatCard>
123133
);

report/src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ export interface ThroughputPercentiles {
166166
gps_max: number;
167167
}
168168

169+
export interface BlockRange {
170+
first_block: number;
171+
last_block: number;
172+
block_count: number;
173+
}
174+
169175
export interface GasStats {
170176
total_gas: number;
171177
avg_gas: number;
@@ -229,6 +235,9 @@ export interface LoadTestResult {
229235
// gated on its presence rather than rendering empty placeholders.
230236
config?: LoadTestConfig;
231237
throughput_timeseries?: ThroughputSample[];
238+
// Optional for back-compat: older runs predate this field. The summary
239+
// section gates the block range stats on its presence.
240+
block_range?: BlockRange;
232241
}
233242

234243
/**

report/src/utils/formatters.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,31 @@ export const formatTps = (n: number): string => `${n.toFixed(1)} tx/s`;
129129

130130
export const formatGps = (n: number): string => formatValue(n, "gas/s");
131131

132+
const WRITTEN_PREFIXES: Record<string, string> = {
133+
"": "",
134+
k: "thousand ",
135+
M: "million ",
136+
G: "billion ",
137+
T: "trillion ",
138+
};
139+
140+
const formatGasWritten = (value: number, suffix: string): string => {
141+
if (value === 0) return `0 gas${suffix}`;
142+
const sortedPrefixes = Object.entries(PREFIXES).sort(([, a], [, b]) => b - a);
143+
for (const [prefix, multiplier] of sortedPrefixes) {
144+
if (Math.abs(value) >= multiplier) {
145+
const written = WRITTEN_PREFIXES[prefix] ?? `${prefix} `;
146+
return `${(value / multiplier).toFixed(1)} ${written}gas${suffix}`;
147+
}
148+
}
149+
return `${value.toFixed(1)} gas${suffix}`;
150+
};
151+
152+
export const formatGasVerbose = (n: number): string => formatGasWritten(n, "");
153+
154+
export const formatGpsVerbose = (n: number): string =>
155+
formatGasWritten(n, "/s");
156+
132157
export const formatPercent = (
133158
numerator: number,
134159
denominator: number,

0 commit comments

Comments
 (0)