From bc4e585e26d9a85a396cbe6765707933d81f80b7 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 11 Feb 2023 13:48:39 +0100 Subject: [PATCH] Don't show timing on error for clearer error output --- common.js | 15 +++++++-------- dist/index.js | 15 +++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/common.js b/common.js index c7a7e2a..0b8d18d 100644 --- a/common.js +++ b/common.js @@ -47,17 +47,16 @@ export async function measure(name, block) { } } -// Same as mesaure() but without the group +// Same as mesaure() but without the group, and no time shown on error export async function time(name, block) { console.log(`> ${name}`) const start = performance.now() - try { - return await block() - } finally { - const end = performance.now() - const duration = (end - start) / 1000.0 - console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`) - } + const value = await block() + const end = performance.now() + + const duration = (end - start) / 1000.0 + console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`) + return value } export function isHeadVersion(rubyVersion) { diff --git a/dist/index.js b/dist/index.js index edaa8ce..ba17f86 100644 --- a/dist/index.js +++ b/dist/index.js @@ -349,17 +349,16 @@ async function measure(name, block) { } } -// Same as mesaure() but without the group +// Same as mesaure() but without the group, and no time shown on error async function time(name, block) { console.log(`> ${name}`) const start = performance.now() - try { - return await block() - } finally { - const end = performance.now() - const duration = (end - start) / 1000.0 - console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`) - } + const value = await block() + const end = performance.now() + + const duration = (end - start) / 1000.0 + console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`) + return value } function isHeadVersion(rubyVersion) {