From cc6f25bf09706d8481b91ee95ffb0d43140e1900 Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Tue, 25 May 2021 16:06:33 +0200 Subject: [PATCH] improved reporting --- src/util/generateCbz.js | 4 +--- src/util/generateEpub.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/util/generateCbz.js b/src/util/generateCbz.js index bd94d23..e144fb1 100644 --- a/src/util/generateCbz.js +++ b/src/util/generateCbz.js @@ -31,16 +31,14 @@ export class CBZGenerator extends BaseGenerator { this.callback(chapterI, i, false); const hash = chapter.links[i]; const URL = `${baseUrl}/${this.opts.quality}/${chapter.hash}/${hash}`; - const start = performance.now(); const res = await this.fetchImage(URL); const image = new ZipPassThrough(`${this.opts.title} ${chapter.number.toString().padStart(chapterCountLength, "0")}/${i.toString().padStart(imageCountLength, "0")}.${hash.substr(hash.lastIndexOf(".") + 1)}`); this.zip.add(image); const data = new Uint8Array(await res.arrayBuffer()); - const end = performance.now() - start; report({ bytes: data.byteLength, cached: res.headers.get("X-Cache") === "HIT", - duration: end, + duration: performance.getEntriesByName(URL)[0].duration, success: Math.floor(res.status / 100) === 2, url: URL }); diff --git a/src/util/generateEpub.js b/src/util/generateEpub.js index 2660f3a..b3dbf3a 100644 --- a/src/util/generateEpub.js +++ b/src/util/generateEpub.js @@ -41,16 +41,14 @@ export class EpubGenerator extends BaseGenerator { this.callback(chapterI, i, false); const hash = chapter.links[i]; const URL = `${baseUrl}/${this.opts.quality}/${chapter.hash}/${hash}`; - const start = performance.now(); const res = await this.fetchImage(URL); const image = new ZipPassThrough("OEBPS/" + hash); this.zip.add(image); const data = new Uint8Array(await res.arrayBuffer()); - const end = performance.now() - start; report({ bytes: data.byteLength, cached: res.headers.get("X-Cache") === "HIT", - duration: end, + duration: performance.getEntriesByName(URL)[0].duration, success: Math.floor(res.status / 100) === 2, url: URL });