Skip to content

Commit 556540a

Browse files
committed
fix(k6): add missing formatPercent and formatBytes functions
The handleSummary function was failing with a ReferenceError because formatPercent and formatBytes were undefined, preventing the JSON artifact from being created in the workflow run.
1 parent ed0a615 commit 556540a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

apps/k6/scripts/stt-live.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,20 @@ function formatDuration(ms) {
294294
if (ms < 3600000) return `${(ms / 60000).toFixed(1)}m`;
295295
return `${(ms / 3600000).toFixed(2)}h`;
296296
}
297+
298+
function formatPercent(value) {
299+
if (!value) return "N/A";
300+
return `${(value * 100).toFixed(2)}%`;
301+
}
302+
303+
function formatBytes(bytes) {
304+
if (!bytes) return "N/A";
305+
const units = ["B", "KB", "MB", "GB"];
306+
let size = bytes;
307+
let unitIndex = 0;
308+
while (size >= 1024 && unitIndex < units.length - 1) {
309+
size /= 1024;
310+
unitIndex++;
311+
}
312+
return `${size.toFixed(2)} ${units[unitIndex]}`;
313+
}

0 commit comments

Comments
 (0)