Measure and output the time conversion takes
This commit is contained in:
parent
58b0856deb
commit
f70ba64629
1 changed files with 9 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs").promises;
|
const fs = require("fs").promises;
|
||||||
|
const { performance } = require("perf_hooks");
|
||||||
const workerpool = require("workerpool");
|
const workerpool = require("workerpool");
|
||||||
const cliProgress = require("cli-progress");
|
const cliProgress = require("cli-progress");
|
||||||
|
|
||||||
|
|
@ -11,9 +12,12 @@ module.exports = async (cachePath, manifestPath, contentPath, book, concurrentJo
|
||||||
console.log("Converting raw downloaded HTML to EPUB chapters");
|
console.log("Converting raw downloaded HTML to EPUB chapters");
|
||||||
const progress = new cliProgress.SingleBar({
|
const progress = new cliProgress.SingleBar({
|
||||||
stopOnComplete: true,
|
stopOnComplete: true,
|
||||||
clearOnComplete: true
|
clearOnComplete: true,
|
||||||
|
format: " {bar} {percentage}% | {time} | {value}/{total}"
|
||||||
}, cliProgress.Presets.shades_classic);
|
}, cliProgress.Presets.shades_classic);
|
||||||
progress.start(chapters.length, 0);
|
|
||||||
|
const start = performance.now();
|
||||||
|
progress.start(chapters.length, 0, { time: " " });
|
||||||
|
|
||||||
const poolOptions = {};
|
const poolOptions = {};
|
||||||
if (concurrentJobs !== undefined) {
|
if (concurrentJobs !== undefined) {
|
||||||
|
|
@ -30,7 +34,8 @@ module.exports = async (cachePath, manifestPath, contentPath, book, concurrentJo
|
||||||
|
|
||||||
warnings.push(...await pool.exec("convertChapter", [chapter, book, inputPath, outputPath]));
|
warnings.push(...await pool.exec("convertChapter", [chapter, book, inputPath, outputPath]));
|
||||||
|
|
||||||
progress.increment();
|
const time = String(Math.round((performance.now() - start) / 1000)).padStart(3) + " s";
|
||||||
|
progress.increment({ time });
|
||||||
}));
|
}));
|
||||||
|
|
||||||
pool.terminate();
|
pool.terminate();
|
||||||
|
|
@ -39,5 +44,5 @@ module.exports = async (cachePath, manifestPath, contentPath, book, concurrentJo
|
||||||
console.warn(warning);
|
console.warn(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("All chapters converted");
|
console.log(`All chapters converted in ${Math.round((performance.now() - start) / 100) / 10} seconds`);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue