From 271ff4b692c3653f5f2ccda1e2cbaa1abd96c9b1 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Mon, 28 Sep 2020 12:25:15 +0200 Subject: [PATCH] log individual timings --- src/restore.ts | 14 +++++++++----- src/save.ts | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/restore.ts b/src/restore.ts index efc50e9..117b6ef 100644 --- a/src/restore.ts +++ b/src/restore.ts @@ -12,10 +12,11 @@ async function run() { const caches = await getCaches(); for (const [type, { name, path, key, restoreKeys }] of Object.entries(caches)) { + const start = Date.now(); + core.startGroup(`Restoring ${name}"…`); + core.info(`Restoring to path "${path}".`); + core.info(`Using keys:\n ${[key, ...restoreKeys].join("\n ")}`); try { - core.startGroup(`Restoring ${name}"…`); - core.info(`Restoring to path "${path}".`); - core.info(`Using keys:\n ${[key, ...restoreKeys].join("\n ")}`); const restoreKey = await cache.restoreCache([path], key, restoreKeys); if (restoreKey) { core.info(`Restored from cache key "${restoreKey}".`); @@ -25,9 +26,12 @@ async function run() { } } catch (e) { core.info(`[warning] ${e.message}`); - } finally { - core.endGroup(); } + const duration = Math.round((Date.now() - start) / 1000); + if (duration) { + core.info(`Took ${duration}s.`); + } + core.endGroup(); } } catch (e) { core.info(`[warning] ${e.message}`); diff --git a/src/save.ts b/src/save.ts index 6eb629f..b01bb41 100644 --- a/src/save.ts +++ b/src/save.ts @@ -38,16 +38,20 @@ async function run() { core.info(`${name} up-to-date.`); continue; } + const start = Date.now(); + core.startGroup(`Saving ${name}…`); + core.info(`Saving path "${path}".`); + core.info(`Using key "${key}".`); try { - core.startGroup(`Saving ${name}…`); - core.info(`Saving path "${path}".`); - core.info(`Using key "${key}".`); await cache.saveCache([path], key); } catch (e) { core.info(`[warning] ${e.message}`); - } finally { - core.endGroup(); } + const duration = Math.round((Date.now() - start) / 1000); + if (duration) { + core.info(`Took ${duration}s.`); + } + core.endGroup(); } } catch (e) { core.info(`[warning] ${e.message}`);