Files
infoscreen3/plugins/profiler/plugin.js
T
Petri Järvisalo 798c85e70f prepare 1.7.1: Refactor build process to use nexe and update dependencies
- Updated package.json to replace pkg with nexe for building executables.
- Added rebuild-native-node20.js for rebuilding native modules for Node.js 20.18.1.
- Introduced test-exe.js to facilitate testing of the generated executable.
- Modified webpack.config.cjs to output bundle.cjs and set libraryTarget to commonjs2.
- Enhanced profiler plugin for memory usage tracking with simplified output.
- Removed unused dependencies and updated existing ones in package.json.
2025-12-05 13:42:12 +02:00

29 lines
895 B
JavaScript

import plugin from "../../modules/plugin.js";
import cli from "../../modules/cli.js";
let prevValue = 0;
let startValue = (process.memoryUsage().rss / 1048576).toFixed(1);
function tickHeapDump() {
setImmediate(function () {
let memMB = (process.memoryUsage().rss / 1048576).toFixed(1);
if (prevValue != memMB) {
let prefix = "▲";
if (memMB < prevValue) {
prefix = "▼";
}
cli.info("Memory: " + prefix + " " + (memMB - prevValue).toFixed(1) + 'Mb' + " start: " + startValue + "Mb now: " + memMB + "Mb (" + (memMB - startValue).toFixed(1) + "Mb)");
prevValue = memMB;
}
});
}
export default class profilerPlugin extends plugin {
onInit() {
tickHeapDump();
setInterval(() => {
tickHeapDump();
}, 5000);
}
}