Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
59cd92cb
Commit
59cd92cb
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add System.Diagnostics based function for getting the CPU load.
parent
149cc59b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxDiagnostics/ATxDiagnostics.cs
+16
-0
16 additions, 0 deletions
ATxDiagnostics/ATxDiagnostics.cs
with
16 additions
and
0 deletions
ATxDiagnostics/ATxDiagnostics.cs
+
16
−
0
View file @
59cd92cb
using
System
;
using
System.Diagnostics
;
using
System.Management
;
using
ATxCommon
;
using
NLog
;
...
...
@@ -24,6 +25,7 @@ namespace ATxDiagnostics
LogManager
.
Configuration
=
logConfig
;
Log
.
Debug
(
Conv
.
BytesToString
(
SystemChecks
.
GetFreeDriveSpace
(
"C:"
)));
GetCpuCounter
();
/*
Log.Debug(SystemChecks.GetCpuUsage());
Log.Debug(SystemChecks.GetCpuUsage());
...
...
@@ -74,5 +76,19 @@ namespace ATxDiagnostics
return
usageInt32
;
}
private
static
void
GetCpuCounter
()
{
var
counter
=
new
PerformanceCounter
(
"Processor"
,
"% Processor Time"
,
"_Total"
);
var
i
=
0
;
while
(
true
)
{
i
++;
//Log.Debug("PerformanceCounter reading {1}: {0}", counter.NextValue(), i);
var
watch
=
Stopwatch
.
StartNew
();
var
reading
=
counter
.
NextValue
();
watch
.
Stop
();
Console
.
WriteLine
(
"reading {1} (took {2} ms): {0}"
,
reading
,
i
,
watch
.
ElapsedMilliseconds
);
System
.
Threading
.
Thread
.
Sleep
(
250
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment