Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dfaast
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Santhosh Kumar
dfaast
Commits
010d3686
Commit
010d3686
authored
May 04, 2024
by
Santhosh Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert to old cpu usage
parent
b1a72fbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
src/example2/.function.py.swp
src/example2/.function.py.swp
+0
-0
src/example2/function.py
src/example2/function.py
+6
-3
No files found.
src/example2/.function.py.swp
deleted
100644 → 0
View file @
b1a72fbc
File deleted
src/example2/function.py
View file @
010d3686
...
@@ -40,17 +40,20 @@ def occupy_cpu(percentage):
...
@@ -40,17 +40,20 @@ def occupy_cpu(percentage):
cpu_percent
=
psutil
.
cpu_percent
()
cpu_percent
=
psutil
.
cpu_percent
()
# Adjust the workload based on the difference between actual and desired CPU usage
# Adjust the workload based on the difference between actual and desired CPU usage
workload
=
min
(
1.0
,
percentage
/
cpu_percent
)
if
cpu_percent
>
0.1
:
workload
=
min
(
1.0
,
percentage
/
cpu_percent
)
else
:
workload
=
1.0
# Start time
# Start time
start_time
=
time
.
time
()
start_time
=
time
.
time
()
# Perform CPU-bound task
# Perform CPU-bound task
while
(
time
.
time
()
-
start_time
)
<
(
workload
):
while
(
time
.
time
()
-
start_time
)
<
(
percentage
/
100
):
pass
pass
# Sleep to balance CPU usage
# Sleep to balance CPU usage
time
.
sleep
(
1
-
workload
)
time
.
sleep
(
1
-
percentage
/
100
)
@
app
.
route
(
'/occupy_cpu/<int:percentage>'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/occupy_cpu/<int:percentage>'
,
methods
=
[
'GET'
])
def
start_cpu_occupier
(
percentage
):
def
start_cpu_occupier
(
percentage
):
...
...
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