本文整理汇总了TypeScript中os.freemem函数的典型用法代码示例。如果您正苦于以下问题:TypeScript freemem函数的具体用法?TypeScript freemem怎么用?TypeScript freemem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了freemem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: computeStartupMetrics
public computeStartupMetrics(): void {
const now = Date.now();
const initialStartup = !!this.isInitialStartup;
const start = initialStartup ? this.start : this.windowLoad;
let totalmem: number;
let freemem: number;
let cpus: { count: number; speed: number; model: string; };
let platform: string;
let release: string;
let loadavg: number[];
let meminfo: IMemoryInfo;
try {
totalmem = os.totalmem();
freemem = os.freemem();
platform = os.platform();
release = os.release();
loadavg = os.loadavg();
meminfo = process.getProcessMemoryInfo();
const rawCpus = os.cpus();
if (rawCpus && rawCpus.length > 0) {
cpus = { count: rawCpus.length, speed: rawCpus[0].speed, model: rawCpus[0].model };
}
} catch (error) {
console.error(error); // be on the safe side with these hardware method calls
}
this._startupMetrics = {
version: 1,
ellapsed: Math.round(this.workbenchStarted.getTime() - start.getTime()),
timers: {
ellapsedExtensions: Math.round(this.afterExtensionLoad.getTime() - this.beforeExtensionLoad.getTime()),
ellapsedExtensionsReady: Math.round(this.afterExtensionLoad.getTime() - start.getTime()),
ellapsedRequire: Math.round(this.afterLoadWorkbenchMain.getTime() - this.beforeLoadWorkbenchMain.getTime()),
ellapsedViewletRestore: Math.round(this.restoreViewletDuration),
ellapsedEditorRestore: Math.round(this.restoreEditorsDuration),
ellapsedWorkbench: Math.round(this.workbenchStarted.getTime() - this.beforeWorkbenchOpen.getTime()),
ellapsedWindowLoadToRequire: Math.round(this.beforeLoadWorkbenchMain.getTime() - this.windowLoad.getTime()),
ellapsedTimersToTimersComputed: Date.now() - now
},
platform,
release,
totalmem,
freemem,
meminfo,
cpus,
loadavg,
initialStartup,
hasAccessibilitySupport: !!this.hasAccessibilitySupport,
emptyWorkbench: this.isEmptyWorkbench
};
if (initialStartup) {
this._startupMetrics.timers.ellapsedAppReady = Math.round(this.appReady.getTime() - this.start.getTime());
this._startupMetrics.timers.ellapsedWindowLoad = Math.round(this.windowLoad.getTime() - this.appReady.getTime());
}
}
开发者ID:fs814,项目名称:vscode,代码行数:59,代码来源:timerService.ts
示例2: init
/**
* Init app
*/
async function init(): Promise<State> {
console.log('Welcome to Misskey!\n');
console.log(chalk.bold('Misskey Core <aoi>'));
let warn = false;
// Get commit info
const commit = await prominence(git).getLastCommit();
console.log(`commit: ${commit.shortHash} ${commit.author.name} <${commit.author.email}>`);
console.log(` ${new Date(parseInt(commit.committedOn, 10) * 1000)}`);
console.log('\nInitializing...\n');
if (IS_DEBUG) {
logWarn('It is not in the Production mode. Do not use in the Production environment.');
}
logInfo(`environment: ${env}`);
// Get machine info
const totalmem = (os.totalmem() / 1024 / 1024 / 1024).toFixed(1);
const freemem = (os.freemem() / 1024 / 1024 / 1024).toFixed(1);
logInfo(`MACHINE: ${os.hostname()}`);
logInfo(`MACHINE: CPU: ${os.cpus().length}core`);
logInfo(`MACHINE: MEM: ${totalmem}GB (available: ${freemem}GB)`);
if (!fs.existsSync(require('./config').configPath)) {
logFailed('Configuration not found');
return State.failed;
}
// Load config
const conf = require('./config').default;
logDone('Success to load configuration');
logInfo(`maintainer: ${conf.maintainer}`);
checkDependencies();
// Check if a port is being used
if (await portUsed.check(conf.port)) {
logFailed(`Port: ${conf.port} is already used!`);
return State.failed;
}
// Try to connect to MongoDB
try {
await initdb(conf);
logDone('Success to connect to MongoDB');
} catch (e) {
logFailed(`MongoDB: ${e}`);
return State.failed;
}
return warn ? State.warn : State.success;
}
开发者ID:syuilo,项目名称:misskey-core,代码行数:60,代码来源:index.ts
示例3: show
public static show(): void {
const totalmem = (os.totalmem() / 1024 / 1024 / 1024).toFixed(1);
const freemem = (os.freemem() / 1024 / 1024 / 1024).toFixed(1);
const logger = new Logger('Machine');
logger.info(`Hostname: ${os.hostname()}`);
logger.info(`Platform: ${process.platform}`);
logger.info(`Architecture: ${process.arch}`);
logger.info(`CPU: ${os.cpus().length} core`);
logger.info(`MEM: ${totalmem}GB (available: ${freemem}GB)`);
}
开发者ID:ha-dai,项目名称:Misskey,代码行数:10,代码来源:machineInfo.ts
示例4: logging
export function logging(args) {
const pid = process.pid;
const processMem = process.memoryUsage();
const rss = processMem.rss;
const heapTotal = processMem.heapTotal;
const heapUsed = processMem.heapUsed;
const osFreeMem = os.freemem();
const osTotalMem = os.totalmem();
const la = os.loadavg();
return `${pid},${args.time},${rss},${heapUsed},${heapTotal},${osFreeMem},${osTotalMem},${la[0]},${la[1]},${la[2]}\n`;
}
开发者ID:ryota0624,项目名称:express-sutylogger,代码行数:11,代码来源:logger.ts
示例5: Date
,(msg: rcf.IMessage): void => {
console.log(new Date().toISOString() + ': msg-rcvd: ' + JSON.stringify(msg));
let gMsg: GridMessage = msg.body;
if (gMsg.type === 'launch-task') {
let task: ITask = gMsg.content;
let TrackingId = tasksTracker.beginTracking(task);
let taskExec = getTaskExec(nodeId, gridDB);
taskExec.on("error", (err: any) => {
console.error(new Date().toISOString() + ": !!! Error running task " + JSON.stringify(task) + ": " + JSON.stringify(err) + " :-(");
// TODO: sent error message to the server
}).on("exec-params", (taskExecParams: ITaskExecParams) => {
tasksTracker.updateTracking(TrackingId, {cmd: taskExecParams.cmd, envJSON: taskExecParams.envJSON});
console.log(new Date().toISOString() + ": running task " + JSON.stringify(task) + " with exec-params=\n" + JSON.stringify(taskExecParams, null, 2));
}).on("started", (pid: number) => {
tasksTracker.updateTracking(TrackingId, {pid});
console.log(new Date().toISOString() + ": task " + JSON.stringify(task) + " started with pid=" + pid);
}).on("finished", (retCode: number) => {
console.log(new Date().toISOString() + ": task " + JSON.stringify(task) + " finished with retCode=" + retCode);
}).run(task)
.then(() => {
tasksTracker.endTracking(TrackingId);
notifyDispatcherTaskComplete(task)
.then(() => {
console.log(new Date().toISOString() + ': <task-complete> notification for task ' + JSON.stringify(task) + ' successfully sent to the dispatcher :-)');
}).catch((err: any) => {
console.error(new Date().toISOString() + ': !!! Error sending <task-complete> notification for task '+ JSON.stringify(task) + ' to the dispatcher :-(');
});
});
} else if (gMsg.type === 'kill-processes-tree') {
let pids: number[] = gMsg.content;
killProcessesTree(pids);
} else if (gMsg.type === 'node-query-status') {
let request: NodeQueryStatusRequest = gMsg.content;
let response: NodeQueryStatusResponse = {
QueryId: request.QueryId
,Status: {
FreeMem: os.freemem()
,TotalMem: os.totalmem()
,UptimeSec: os.uptime()
,RunningTasks: tasksTracker.toJSON()
}
};
sendNodeQueryStatusResponse(response)
.then(() => {
}).catch((err: any) => {
console.error(new Date().toISOString() + ': !!! Error sending back <node-query-status> message: ' + JSON.stringify(err));
});
}
},{})
开发者ID:wchang28,项目名称:node-grid-2,代码行数:49,代码来源:launcherApp.ts
示例6: getMachineInfo
export function getMachineInfo(): IMachineInfo {
const MB = 1024 * 1024;
const GB = 1024 * MB;
const machineInfo: IMachineInfo = {
os: `${os.type()} ${os.arch()} ${os.release()}`,
memory: `${(os.totalmem() / GB).toFixed(2)}GB (${(os.freemem() / GB).toFixed(2)}GB free)`,
vmHint: `${Math.round((virtualMachineHint.value() * 100))}%`,
};
const cpus = os.cpus();
if (cpus && cpus.length > 0) {
machineInfo.cpus = `${cpus[0].model} (${cpus.length} x ${cpus[0].speed})`;
}
return machineInfo;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:17,代码来源:diagnosticsService.ts
示例7: progress_report
function progress_report() {
var now = new Date();
var period = (now.getTime() - server.timer.mark) / 1000
var rate = server.timer.hits / period
var stats = {
type: "status_report",
server: settings.api.hostname,
version: settings.api.version,
date: now.toISOString(),
msg_rate: rate,
client_count: server.clients.list.length,
freemem: os.freemem()
}
db.activity_add(stats)
var srep = 'status report - ' + rate.toFixed(1) + ' hits/sec. ' +
server.clients.list.length + ' clients.'
console.log(srep)
pump(stats)
}
开发者ID:icecondor,项目名称:api,代码行数:19,代码来源:api.ts
示例8:
osUtils.cpuUsage(cpuUsage => {
const disk = diskusage.checkSync(os.platform() == 'win32' ? 'c:' : '/');
event.stream.emit('status', {
node: {
release: (process as any).release.name,
lts: (process as any).release.lts,
version: process.version
},
machine: os.hostname(),
pid: process.pid,
uptime: process.uptime(),
cpuUsage: cpuUsage,
mem: {
total: os.totalmem(),
free: os.freemem()
},
disk
});
});
开发者ID:syuilo,项目名称:accesses,代码行数:19,代码来源:report-status.ts
示例9: formatEnvironment
function formatEnvironment(info: IMainProcessInfo): string {
const MB = 1024 * 1024;
const GB = 1024 * MB;
const output: string[] = [];
output.push(`Version: ${pkg.name} ${pkg.version} (${product.commit || 'Commit unknown'}, ${product.date || 'Date unknown'})`);
output.push(`OS Version: ${os.type()} ${os.arch()} ${os.release()})`);
const cpus = os.cpus();
if (cpus && cpus.length > 0) {
output.push(`CPUs: ${cpus[0].model} (${cpus.length} x ${cpus[0].speed})`);
}
output.push(`Memory (System): ${(os.totalmem() / GB).toFixed(2)}GB (${(os.freemem() / GB).toFixed(2)}GB free)`);
if (!isWindows) {
output.push(`Load (avg): ${os.loadavg().map(l => Math.round(l)).join(', ')}`); // only provided on Linux/macOS
}
output.push(`VM: ${Math.round((virtualMachineHint.value() * 100))}%`);
output.push(`Screen Reader: ${app.isAccessibilitySupportEnabled() ? 'yes' : 'no'}`);
return output.join('\n');
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:20,代码来源:diagnostics.ts
示例10: main
async function main () {
let ipcTestResult: string
try {
await doctor.testTcp()
ipcTestResult = 'PASS'
} catch (err) {
console.log(err)
ipcTestResult = 'FAIL. Please check your tcp network, Wechaty need to listen on localhost and connect to it.'
}
console.log(`
#### Wechaty Doctor
1. Wechaty version: ${wechaty.version()}
2. ${os.type()} ${os.arch()} version ${os.release()} memory ${Math.floor(os.freemem() / 1024 / 1024)}/${Math.floor(os.totalmem() / 1024 / 1024)} MB
3. Docker: ${config.docker}
4. Node version: ${process.version}
5. Tcp IPC TEST: ${ipcTestResult}
`)
}
开发者ID:KiddoLin,项目名称:wechaty,代码行数:22,代码来源:doctor.ts
示例11: getSystemInfo
function getSystemInfo(info: IMainProcessInfo): SystemInfo {
const MB = 1024 * 1024;
const GB = 1024 * MB;
const systemInfo: SystemInfo = {
'Memory (System)': `${(os.totalmem() / GB).toFixed(2)}GB (${(os.freemem() / GB).toFixed(2)}GB free)`,
VM: `${Math.round((virtualMachineHint.value() * 100))}%`,
'Screen Reader': `${app.isAccessibilitySupportEnabled() ? 'yes' : 'no'}`,
'Process Argv': `${info.mainArguments.join(' ')}`
};
const cpus = os.cpus();
if (cpus && cpus.length > 0) {
systemInfo.CPUs = `${cpus[0].model} (${cpus.length} x ${cpus[0].speed})`;
}
if (!isWindows) {
systemInfo['Load (avg)'] = `${os.loadavg().map(l => Math.round(l)).join(', ')}`;
}
return systemInfo;
}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:23,代码来源:diagnostics.ts
示例12:
result = os.homedir();
result = os.endianness();
result = os.hostname();
result = os.type();
result = os.platform();
result = os.arch();
result = os.release();
result = os.EOL;
}
{
let result: number;
result = os.uptime();
result = os.totalmem();
result = os.freemem();
}
{
let result: number[];
result = os.loadavg();
}
{
let result: os.CpuInfo[];
result = os.cpus();
}
{
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:31,代码来源:node-tests.ts
示例13: _computeStartupMetrics
public _computeStartupMetrics(): void {
const now = Date.now();
const initialStartup = !!this.isInitialStartup;
const start = initialStartup ? this.start : this.windowLoad;
let totalmem: number;
let freemem: number;
let cpus: { count: number; speed: number; model: string; };
let platform: string;
let release: string;
let arch: string;
let loadavg: number[];
let meminfo: IMemoryInfo;
let isVMLikelyhood: number;
try {
totalmem = os.totalmem();
freemem = os.freemem();
platform = os.platform();
release = os.release();
arch = os.arch();
loadavg = os.loadavg();
meminfo = process.getProcessMemoryInfo();
isVMLikelyhood = Math.round((virtualMachineHint.value() * 100));
const rawCpus = os.cpus();
if (rawCpus && rawCpus.length > 0) {
cpus = { count: rawCpus.length, speed: rawCpus[0].speed, model: rawCpus[0].model };
}
} catch (error) {
// ignore, be on the safe side with these hardware method calls
}
this._startupMetrics = {
version: 1,
ellapsed: this.workbenchStarted - start,
timers: {
ellapsedExtensions: this.afterExtensionLoad - this.beforeExtensionLoad,
ellapsedExtensionsReady: this.afterExtensionLoad - start,
ellapsedRequire: this.afterLoadWorkbenchMain - this.beforeLoadWorkbenchMain,
ellapsedViewletRestore: this.restoreViewletDuration,
ellapsedEditorRestore: this.restoreEditorsDuration,
ellapsedWorkbench: this.workbenchStarted - this.beforeWorkbenchOpen,
ellapsedWindowLoadToRequire: this.beforeLoadWorkbenchMain - this.windowLoad,
ellapsedTimersToTimersComputed: Date.now() - now
},
platform,
release,
arch,
totalmem,
freemem,
meminfo,
cpus,
loadavg,
initialStartup,
isVMLikelyhood,
hasAccessibilitySupport: !!this.hasAccessibilitySupport,
emptyWorkbench: this.isEmptyWorkbench
};
if (initialStartup) {
this._startupMetrics.timers.ellapsedAppReady = this.appReady - this.start;
this._startupMetrics.timers.ellapsedWindowLoad = this.windowLoad - this.appReady;
}
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:66,代码来源:timerService.ts
示例14: _computeStartupMetrics
public _computeStartupMetrics(): void {
const now = Date.now();
const initialStartup = !!this.isInitialStartup;
const start = initialStartup ? this.start : this.windowLoad;
let totalmem: number;
let freemem: number;
let cpus: { count: number; speed: number; model: string; };
let platform: string;
let release: string;
let arch: string;
let loadavg: number[];
let meminfo: IMemoryInfo;
let isVMLikelyhood: number;
try {
totalmem = os.totalmem();
freemem = os.freemem();
platform = os.platform();
release = os.release();
arch = os.arch();
loadavg = os.loadavg();
meminfo = process.getProcessMemoryInfo();
isVMLikelyhood = Math.round((virtualMachineHint.value() * 100));
const rawCpus = os.cpus();
if (rawCpus && rawCpus.length > 0) {
cpus = { count: rawCpus.length, speed: rawCpus[0].speed, model: rawCpus[0].model };
}
} catch (error) {
// ignore, be on the safe side with these hardware method calls
}
let nlsStart = perf.getEntry('mark', 'nlsGeneration:start');
let nlsEnd = perf.getEntry('mark', 'nlsGeneration:end');
let nlsTime = nlsStart && nlsEnd ? nlsEnd.startTime - nlsStart.startTime : 0;
this._startupMetrics = {
version: 1,
ellapsed: perf.getEntry('mark', 'didStartWorkbench').startTime - start,
timers: {
ellapsedExtensions: perf.getDuration('willLoadExtensions', 'didLoadExtensions'),
ellapsedExtensionsReady: perf.getEntry('mark', 'didLoadExtensions').startTime - start,
ellapsedRequire: perf.getDuration('willLoadWorkbenchMain', 'didLoadWorkbenchMain'),
ellapsedEditorRestore: perf.getDuration('willRestoreEditors', 'didRestoreEditors'),
ellapsedViewletRestore: perf.getDuration('willRestoreViewlet', 'didRestoreViewlet'),
ellapsedWorkbench: perf.getDuration('willStartWorkbench', 'didStartWorkbench'),
ellapsedWindowLoadToRequire: perf.getEntry('mark', 'willLoadWorkbenchMain').startTime - this.windowLoad,
ellapsedTimersToTimersComputed: Date.now() - now,
ellapsedNlsGeneration: nlsTime
},
platform,
release,
arch,
totalmem,
freemem,
meminfo,
cpus,
loadavg,
initialStartup,
isVMLikelyhood,
hasAccessibilitySupport: !!this.hasAccessibilitySupport,
emptyWorkbench: this.isEmptyWorkbench
};
if (initialStartup) {
this._startupMetrics.timers.ellapsedAppReady = perf.getDuration('main:started', 'main:appReady');
this._startupMetrics.timers.ellapsedWindowLoad = this.windowLoad - perf.getEntry('mark', 'main:appReady').startTime;
}
}
开发者ID:AllureFer,项目名称:vscode,代码行数:70,代码来源:timerService.ts
示例15: install_optional_cpu_and_memory_usage_node
export function install_optional_cpu_and_memory_usage_node(server: any) {
const engine = server.engine;
assert(engine instanceof ServerEngine);
let usage: any;
try {
usage = require("usage");
} catch (err) {
console.log("err", err.message);
usage = null;
// xx return;
}
const addressSpace = engine.addressSpace;
const namespace = addressSpace.getOwnNamespace();
const folder = addressSpace.findNode(ObjectIds.Server_VendorServerInfo);
let usage_result = {memory: 0, cpu: 100};
const pid = process.pid;
if (usage) {
const options = {keepHistory: true};
setInterval(() => {
usage.lookup(pid, options, (err: Error| null, result: any) => {
usage_result = result;
console.log("result Used Memory: ", humanize.filesize(result.memory), " CPU ", Math.round(result.cpu), " %");
if (err) { console.log("err ", err); }
});
}, 1000);
namespace.addVariable({
organizedBy: folder,
browseName: "CPUUsage",
dataType: "Double",
description: "Current CPU usage of the server process",
minimumSamplingInterval: 1000,
nodeId: "s=CPUUsage",
value: {
get: () => {
if (!usage_result) {
return StatusCodes.BadResourceUnavailable;
}
return new Variant({dataType: DataType.Double, value: Math.round(usage_result.cpu)});
}
}
});
addVariableWithHumanizeText(namespace, {
browseName: "MemoryUsage",
dataType: "Number",
description: "Current memory usage of the server process",
minimumSamplingInterval: 1000,
nodeId: "s=MemoryUsage",
organizedBy: folder,
value: {
get: () => {
if (!usage_result) {
return StatusCodes.BadResourceUnavailable;
}
return new Variant({dataType: DataType.UInt32, value: usage_result.memory});
}
}
});
} else {
console.log("skipping installation of cpu_usage and memory_usage nodes");
}
namespace.addVariable({
organizedBy: folder,
browseName: "PercentageMemoryUsed",
dataType: "Number",
description: "% of memory used by the server",
minimumSamplingInterval: 1000,
nodeId: "s=PercentageMemoryUsed",
value: {
get() {
const percent_used = Math.round((os.totalmem() - os.freemem()) / os.totalmem() * 100);
return new Variant({dataType: DataType.Double, value: percent_used});
}
}
});
addVariableWithHumanizeText(namespace, {
organizedBy: folder,
accessLevel: "CurrentRead",
browseName: "SystemMemoryTotal",
dataType: "Number",
description: "Total Memory usage of the server",
minimumSamplingInterval: 1000,
//.........这里部分代码省略.........
开发者ID:node-opcua,项目名称:node-opcua,代码行数:101,代码来源:vendor_diagnostic_nodes.ts
注:本文中的os.freemem函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论