mirror of
https://github.com/danbulant/Mangades
synced 2026-07-07 20:10:36 +00:00
use performance instead of timing api
This commit is contained in:
parent
db43492659
commit
ff730c8916
2 changed files with 6 additions and 2 deletions
|
|
@ -31,14 +31,16 @@ export class CBZGenerator extends BaseGenerator {
|
||||||
this.callback(chapterI, i, false);
|
this.callback(chapterI, i, false);
|
||||||
const hash = chapter.links[i];
|
const hash = chapter.links[i];
|
||||||
const URL = `${baseUrl}/${this.opts.quality}/${chapter.hash}/${hash}`;
|
const URL = `${baseUrl}/${this.opts.quality}/${chapter.hash}/${hash}`;
|
||||||
|
const start = performance.now();
|
||||||
const res = await this.fetchImage(URL);
|
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)}`);
|
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);
|
this.zip.add(image);
|
||||||
const data = new Uint8Array(await res.arrayBuffer());
|
const data = new Uint8Array(await res.arrayBuffer());
|
||||||
|
const end = performance.now() - start;
|
||||||
report({
|
report({
|
||||||
bytes: data.byteLength,
|
bytes: data.byteLength,
|
||||||
cached: res.headers.get("X-Cache") === "HIT",
|
cached: res.headers.get("X-Cache") === "HIT",
|
||||||
duration: performance.getEntriesByName(URL)[0].duration,
|
duration: end,
|
||||||
success: Math.floor(res.status / 100) === 2,
|
success: Math.floor(res.status / 100) === 2,
|
||||||
url: URL
|
url: URL
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,16 @@ export class EpubGenerator extends BaseGenerator {
|
||||||
this.callback(chapterI, i, false);
|
this.callback(chapterI, i, false);
|
||||||
const hash = chapter.links[i];
|
const hash = chapter.links[i];
|
||||||
const URL = `${baseUrl}/${this.opts.quality}/${chapter.hash}/${hash}`;
|
const URL = `${baseUrl}/${this.opts.quality}/${chapter.hash}/${hash}`;
|
||||||
|
const start = performance.now();
|
||||||
const res = await this.fetchImage(URL);
|
const res = await this.fetchImage(URL);
|
||||||
const image = new ZipPassThrough("OEBPS/" + hash);
|
const image = new ZipPassThrough("OEBPS/" + hash);
|
||||||
this.zip.add(image);
|
this.zip.add(image);
|
||||||
const data = new Uint8Array(await res.arrayBuffer());
|
const data = new Uint8Array(await res.arrayBuffer());
|
||||||
|
const end = performance.now() - start;
|
||||||
report({
|
report({
|
||||||
bytes: data.byteLength,
|
bytes: data.byteLength,
|
||||||
cached: res.headers.get("X-Cache") === "HIT",
|
cached: res.headers.get("X-Cache") === "HIT",
|
||||||
duration: performance.getEntriesByName(URL)[0].duration,
|
duration: end,
|
||||||
success: Math.floor(res.status / 100) === 2,
|
success: Math.floor(res.status / 100) === 2,
|
||||||
url: URL
|
url: URL
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue