@actyx/sdk
Version:
Actyx SDK
39 lines • 1.51 kB
JavaScript
;
/*
* Actyx SDK: Functions for writing distributed apps
* deployed on peer-to-peer networks, without any servers.
*
* Copyright (C) 2021 Actyx AG
*/
// utilities that are specific to the runtime / execution environment
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMemoryUsage = exports.isNode = void 0;
// true if we are probably running on nodejs
exports.isNode = typeof process === 'object' && process.release && process.release.name === 'node';
// getting memory usage in bytes
function getMemoryUsage() {
try {
if (exports.isNode) {
// deconstruct process.memoryUsage() to change the names of the properties
const { heapUsed: usedJSHeapSize, heapTotal: totalJSHeapSize, external: externalSize, rss: residentSetSize, } = process.memoryUsage();
return { usedJSHeapSize, totalJSHeapSize, externalSize, residentSetSize };
}
else {
// deconstruct window.performance.memory since it is not enumerable
const { usedJSHeapSize, totalJSHeapSize, jsHeapSizeLimit,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} = window.performance.memory;
return {
usedJSHeapSize,
totalJSHeapSize,
jsHeapSizeLimit,
};
}
}
catch (_) {
/* ignore the error */
}
return {};
}
exports.getMemoryUsage = getMemoryUsage;
//# sourceMappingURL=runtime.js.map