Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
catHardware
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶腾飞
catHardware
Commits
dfb647c1
Commit
dfb647c1
authored
Mar 27, 2022
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022年3月27日:加快CPU获取信息的速度
parent
4d99535a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
13 deletions
+27
-13
README.md
+3
-0
catHardware.exe
+0
-0
main.go
+24
-13
No files found.
README.md
View file @
dfb647c1
...
@@ -39,3 +39,5 @@ Get-PhysicalDisk
...
@@ -39,3 +39,5 @@ Get-PhysicalDisk
2022年3月19日:修复无法找到内存总量信息,并行获取硬件信息
2022年3月19日:修复无法找到内存总量信息,并行获取硬件信息
2022年3月26日:增加内存的DDR信息
2022年3月26日:增加内存的DDR信息
2022年3月27日:加快CPU获取信息的速度
\ No newline at end of file
查看CPU内存硬盘小工具
.exe
→
catHardware
.exe
View file @
dfb647c1
No preview for this file type
main.go
View file @
dfb647c1
...
@@ -83,19 +83,30 @@ func PSCommandOutputNoSplit(cmd string) (string, error) {
...
@@ -83,19 +83,30 @@ func PSCommandOutputNoSplit(cmd string) (string, error) {
}
}
func
getHardwareCPUForPS
()
(
string
,
string
,
string
,
string
)
{
func
getHardwareCPUForPS
()
(
string
,
string
,
string
,
string
)
{
var
c
,
j
int
var
cpuCount
,
cpuName
,
cpuCores
,
cpuLogicalProcessors
string
cpuUN
,
_
:=
PSCommandOutputNoSplit
(
"Get-WmiObject -Class Win32_Processor | select Name,NumberOfCores,NumberOfLogicalProcessors | format-list"
)
for
_
,
line
:=
range
strings
.
Split
(
cpuUN
,
"
\n
"
)
{
if
strings
.
Index
(
line
,
"Name"
)
!=
-
1
{
mi
:=
strings
.
TrimSpace
(
strings
.
Split
(
line
,
":"
)[
1
])
cpuName
=
mi
c
++
}
else
if
strings
.
Index
(
line
,
"NumberOfCores"
)
!=
-
1
{
mi
:=
strings
.
TrimSpace
(
strings
.
Split
(
line
,
":"
)[
1
])
cpuCores
=
mi
c
++
}
else
if
strings
.
Index
(
line
,
"NumberOfLogicalProcessors"
)
!=
-
1
{
mi
:=
strings
.
TrimSpace
(
strings
.
Split
(
line
,
":"
)[
1
])
cpuLogicalProcessors
=
mi
c
++
}
if
c
==
3
{
c
=
0
j
++
}
cpuNameUN
,
_
:=
PSCommandOutputNoSplit
(
"Get-WmiObject -Class Win32_Processor | Select Name"
)
cpuCount
=
strconv
.
Itoa
(
j
)
cpuName
:=
strings
.
TrimSpace
(
strings
.
Split
(
cpuNameUN
,
"
\n
"
)[
3
])
}
cpuCountUN
,
_
:=
PSCommandOutputNoSplit
(
"Get-WmiObject -Class Win32_Processor | select Name |measure | select count"
)
cpuCount
:=
strings
.
TrimSpace
(
strings
.
Split
(
cpuCountUN
,
"
\n
"
)[
3
])
cpuCoresUN
,
_
:=
PSCommandOutputNoSplit
(
"Get-WmiObject -Class Win32_Processor | select NumberOfCores"
)
cpuCores
:=
strings
.
TrimSpace
(
strings
.
Split
(
cpuCoresUN
,
"
\n
"
)[
3
])
cpuLogicalProcessorsUN
,
_
:=
PSCommandOutputNoSplit
(
"Get-WmiObject -Class Win32_Processor | select NumberOfLogicalProcessors"
)
cpuLogicalProcessors
:=
strings
.
TrimSpace
(
strings
.
Split
(
cpuLogicalProcessorsUN
,
"
\n
"
)[
3
])
return
cpuCount
,
cpuName
,
cpuCores
,
cpuLogicalProcessors
return
cpuCount
,
cpuName
,
cpuCores
,
cpuLogicalProcessors
}
}
func
getHardwareMemoryForPS
()
([]
int
,
[]
string
,
[]
string
,
int
)
{
func
getHardwareMemoryForPS
()
([]
int
,
[]
string
,
[]
string
,
int
)
{
...
@@ -222,7 +233,7 @@ func main() {
...
@@ -222,7 +233,7 @@ func main() {
var
ch
=
make
(
chan
int
)
var
ch
=
make
(
chan
int
)
var
Memory
,
Disk
string
var
Memory
,
Disk
string
fmt
.
Println
(
"查看硬件(CPU、内存、硬盘)小工具 -- made in 陶腾飞(2022年3月2
6
日)"
)
fmt
.
Println
(
"查看硬件(CPU、内存、硬盘)小工具 -- made in 陶腾飞(2022年3月2
7
日)"
)
// cpu
// cpu
go
func
()
{
go
func
()
{
<-
ch
<-
ch
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment