本文整理汇总了TypeScript中os.loadavg函数的典型用法代码示例。如果您正苦于以下问题:TypeScript loadavg函数的具体用法?TypeScript loadavg怎么用?TypeScript loadavg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loadavg函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例2: 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`;
}
示例3: 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');
}
示例4: getSystemInfo
async getSystemInfo(launchService: ILaunchService): Promise<SystemInfo> {
const info = await launchService.getMainProcessInfo();
const { memory, vmHint, os, cpus } = getMachineInfo();
const systemInfo: SystemInfo = {
os,
memory,
cpus,
vmHint,
processArgs: `${info.mainArguments.join(' ')}`,
gpuStatus: app.getGPUFeatureStatus(),
screenReader: `${app.isAccessibilitySupportEnabled() ? 'yes' : 'no'}`,
remoteData: (await launchService.getRemoteDiagnostics({ includeProcesses: false, includeWorkspaceMetadata: false })).filter((x): x is IRemoteDiagnosticInfo => !(x instanceof Error))
};
if (!isWindows) {
systemInfo.load = `${osLib.loadavg().map(l => Math.round(l)).join(', ')}`;
}
return Promise.resolve(systemInfo);
}
示例5: 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;
}
示例6:
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();
}
{
let result: { [index: string]: os.NetworkInterfaceInfo[] };
result = os.networkInterfaces();
}
}
示例7: _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;
}
}
示例8: _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;
}
}