Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
6b46db8b
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b46db8b
编写于
11月 29, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ps
💄
上级
e83e2d21
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
30 deletion
+29
-30
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+29
-30
未找到文件。
src/vs/code/electron-main/main.ts
浏览文件 @
6b46db8b
...
...
@@ -154,9 +154,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
if
(
environmentService
.
args
.
ps
)
{
return
service
.
getMainProcessInfo
().
then
(
info
=>
{
return
listProcesses
(
info
.
mainPID
).
then
(
rootProcess
=>
{
const
output
:
string
[]
=
[];
formatProcess
(
info
,
output
,
rootProcess
,
0
);
console
.
log
(
output
.
join
(
'
\n
'
));
console
.
log
(
formatProcessList
(
info
,
rootProcess
));
return
TPromise
.
wrapError
(
new
ExpectedError
());
});
...
...
@@ -209,35 +207,36 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
return
setup
(
true
);
}
function
formatProcess
(
info
:
IMainProcessInfo
,
output
:
string
[],
item
:
ProcessItem
,
indent
:
number
):
void
{
const
isRoot
=
(
indent
===
0
);
function
formatProcessList
(
info
:
IMainProcessInfo
,
rootProcess
:
ProcessItem
):
string
{
const
mapPidToWindowTitle
=
new
Map
<
number
,
string
>
();
info
.
windows
.
forEach
(
window
=>
mapPidToWindowTitle
.
set
(
window
.
pid
,
window
.
title
));
const
MB
=
1024
*
1024
;
const
GB
=
1024
*
MB
;
if
(
isRoot
)
{
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)`
);
output
.
push
(
`Load (avg):
${
os
.
loadavg
().
map
(
l
=>
Math
.
round
(
l
)).
join
(
'
,
'
)}
`
);
output
.
push
(
`VM:
${
Math
.
round
((
virtualMachineHint
.
value
()
*
100
))}
`
);
output
.
push
(
`Screen Reader:
${
app
.
isAccessibilitySupportEnabled
()
?
'
yes
'
:
'
no
'
}
`
);
output
.
push
(
''
);
output
.
push
(
'
Window PID
\t
Title
'
);
info
.
windows
.
forEach
(
window
=>
{
if
(
window
.
title
===
'
Shared Process
'
)
{
return
;
// skip shared process
}
output
.
push
(
`
${
pad
(
window
.
pid
,
10
,
'
'
)}
\t
${
window
.
title
}
`
);
});
output
.
push
(
''
);
output
.
push
(
'
CPU %
\t
Mem MB
\t
Process
'
);
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)`
);
output
.
push
(
`Load (avg):
${
os
.
loadavg
().
map
(
l
=>
Math
.
round
(
l
)).
join
(
'
,
'
)}
`
);
output
.
push
(
`VM:
${
Math
.
round
((
virtualMachineHint
.
value
()
*
100
))}
`
);
output
.
push
(
`Screen Reader:
${
app
.
isAccessibilitySupportEnabled
()
?
'
yes
'
:
'
no
'
}
`
);
output
.
push
(
''
);
output
.
push
(
'
CPU %
\t
Mem MB
\t
Process
'
);
formatProcessItem
(
mapPidToWindowTitle
,
output
,
rootProcess
,
0
);
return
output
.
join
(
'
\n
'
);
}
function
formatProcessItem
(
mapPidToWindowTitle
:
Map
<
number
,
string
>
,
output
:
string
[],
item
:
ProcessItem
,
indent
:
number
):
void
{
const
isRoot
=
(
indent
===
0
);
const
MB
=
1024
*
1024
;
// Format name with indent
let
name
:
string
;
...
...
@@ -247,14 +246,14 @@ function formatProcess(info: IMainProcessInfo, output: string[], item: ProcessIt
name
=
`
${
repeat
(
'
'
,
indent
)}
${
item
.
name
}
`
;
if
(
item
.
name
===
'
renderer
'
)
{
name
=
`
${
name
}
(
pid:
${
item
.
pid
}
)`
;
name
=
`
${
name
}
(
${
mapPidToWindowTitle
.
get
(
item
.
pid
)
}
)`
;
}
}
output
.
push
(
`
${
pad
(
Number
(
item
.
load
.
toFixed
(
0
)),
5
,
'
'
)}
\t
${
pad
(
Number
(((
os
.
totalmem
()
*
(
item
.
mem
/
100
))
/
MB
).
toFixed
(
0
)),
6
,
'
'
)}
\t
${
name
}
`
);
// Recurse into children if any
if
(
Array
.
isArray
(
item
.
children
))
{
item
.
children
.
forEach
(
child
=>
formatProcess
(
info
,
output
,
child
,
indent
+
1
));
item
.
children
.
forEach
(
child
=>
formatProcess
Item
(
mapPidToWindowTitle
,
output
,
child
,
indent
+
1
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录