forked from DebaucheryLibrarian/traxxx
Added total run time indicator.
This commit is contained in:
parent
24cd92807c
commit
b5b09a7dce
10
src/app.js
10
src/app.js
|
@ -1,12 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
const startTime = new Date();
|
||||
|
||||
const config = require('config');
|
||||
const util = require('util');
|
||||
const unprint = require('unprint');
|
||||
// const log = require('why-is-node-running');
|
||||
const Inspector = require('inspector-api');
|
||||
const fs = require('fs').promises;
|
||||
const dayjs = require('dayjs');
|
||||
const { format, formatDistanceStrict } = require('date-fns');
|
||||
|
||||
const argv = require('./argv');
|
||||
const initServer = require('./web/server');
|
||||
|
@ -53,7 +55,7 @@ function logActive() {
|
|||
|
||||
async function snapshotMemory(trigger) {
|
||||
const profile = await inspector.heap.takeSnapshot();
|
||||
const filepath = `traxxx_snapshot_${trigger}M_${dayjs().format('YYYY-MM-DD_HH-mm-ss')}.heapsnapshot`;
|
||||
const filepath = `traxxx_snapshot_${trigger}M_${format(new Date(), 'yyyy-MM-dd_HH-mm-ss')}.heapsnapshot`;
|
||||
|
||||
logger.info(`Starting heap snapshot, memory usage: ${process.memoryUsage.rss() / 1000000} MB`);
|
||||
|
||||
|
@ -67,7 +69,7 @@ async function stopMemorySample(snapshotTriggers) {
|
|||
const usage = process.memoryUsage.rss() / 1000000;
|
||||
|
||||
const profile = await inspector.heap.stopSampling();
|
||||
const filepath = `traxxx_sample_${dayjs().format('YYYY-MM-DD_HH-mm-ss')}.heapprofile`;
|
||||
const filepath = `traxxx_sample_${format(new Date(), 'yyyy-MM-dd_HH-mm-ss')}.heapprofile`;
|
||||
|
||||
await inspector.heap.disable();
|
||||
await fs.writeFile(filepath, JSON.stringify(profile));
|
||||
|
@ -208,6 +210,8 @@ async function init() {
|
|||
|
||||
await associateMovieScenes(storedMovies, [...storedScenes, ...storedMovieScenes]);
|
||||
}
|
||||
|
||||
logger.info(`Completed in ${formatDistanceStrict(new Date(), startTime)}`);
|
||||
} catch (error) {
|
||||
console.trace(error);
|
||||
logger.error(error);
|
||||
|
|
Loading…
Reference in New Issue