• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript os.loadavg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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());
		}
	}
开发者ID:fs814,项目名称:vscode,代码行数:59,代码来源:timerService.ts


示例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`;
}
开发者ID:ryota0624,项目名称:express-sutylogger,代码行数:11,代码来源:logger.ts


示例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');
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:20,代码来源:diagnostics.ts


示例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);
	}
开发者ID:PKRoma,项目名称:vscode,代码行数:21,代码来源:diagnosticsService.ts


示例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;
}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:23,代码来源:diagnostics.ts


示例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();
    }
}
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:30,代码来源:node-tests.ts


示例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;
		}
	}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:66,代码来源:timerService.ts


示例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;
		}
	}
开发者ID:AllureFer,项目名称:vscode,代码行数:70,代码来源:timerService.ts



注:本文中的os.loadavg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript os.networkInterfaces函数代码示例发布时间:2022-05-25
下一篇:
TypeScript os.hostname函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap