How to plot performance data based on process ID?

조회 수: 2 (최근 30일)
Igenyar
Igenyar 2023년 4월 4일
댓글: Igenyar 2023년 4월 4일
I have the following performance data. Column 1 is time, Column 2 is the process ID and Column 3 is CPU usage. First, I want to plot by each process ID but I don't want to hard code the process ID because I like to run it over multiple machines. Second, I want to plot a total usage. That is, at each time, add all the CPU together across all process ID's. Thank you for the help.
1680569427 83321 73.3
1680569427 83325 0.0
1680569427 83326 0.0
1680569427 83327 0.0
1680569427 83328 0.0
1680569427 83329 0.0
1680569427 83331 0.0
1680569427 83332 0.0
1680569427 83333 0.0
1680569427 83334 0.0
1680569427 83335 0.0
1680569427 83336 0.0
1680569429 83321 40.0
1680569429 83325 0.0
1680569429 83326 0.0
1680569429 83327 0.0
1680569429 83328 0.0
1680569429 83329 0.0
1680569429 83331 0.0
1680569429 83332 0.0
1680569429 83333 0.0
1680569429 83334 0.0
1680569429 83335 0.0
1680569429 83336 0.0
1680569431 83321 86.7
1680569431 83326 6.7
1680569431 83327 6.7
1680569431 83325 0.0
1680569431 83328 0.0
1680569431 83329 0.0
1680569431 83331 0.0
1680569431 83332 0.0
1680569431 83333 0.0
1680569431 83334 0.0
1680569431 83335 0.0
1680569431 83336 0.0

채택된 답변

VBBV
VBBV 2023년 4월 4일
편집: VBBV 2023년 4월 4일
Data = [1680569427 83321 73.3
1680569427 83325 0.0
1680569427 83326 0.0
1680569427 83327 0.0
1680569427 83328 0.0
1680569427 83329 0.0
1680569427 83331 0.0
1680569427 83332 0.0
1680569427 83333 0.0
1680569427 83334 0.0
1680569427 83335 0.0
1680569427 83336 0.0
1680569429 83321 40.0
1680569429 83325 0.0
1680569429 83326 0.0
1680569429 83327 0.0
1680569429 83328 0.0
1680569429 83329 0.0
1680569429 83331 0.0
1680569429 83332 0.0
1680569429 83333 0.0
1680569429 83334 0.0
1680569429 83335 0.0
1680569429 83336 0.0
1680569431 83321 86.7
1680569431 83326 6.7
1680569431 83327 6.7
1680569431 83325 0.0
1680569431 83328 0.0
1680569431 83329 0.0
1680569431 83331 0.0
1680569431 83332 0.0
1680569431 83333 0.0
1680569431 83334 0.0
1680569431 83335 0.0
1680569431 83336 0.0];
PID = Data(:,2);
Usage_CPU = Data(:,3);
Time = datetime(Data(:,1),'ConvertFrom','posix')
Time = 36×1 datetime array
04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:27 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:29 04-Apr-2023 00:50:31 04-Apr-2023 00:50:31 04-Apr-2023 00:50:31 04-Apr-2023 00:50:31 04-Apr-2023 00:50:31 04-Apr-2023 00:50:31
subplot(211)
plot(Time, PID); title('Process ID')
subplot(212)
plot(Time, cumsum(Usage_CPU)); title('Total CPU usage')
  댓글 수: 4
VBBV
VBBV 2023년 4월 4일
편집: VBBV 2023년 4월 4일
Since there are only three process ID (PID) with finite CPU usage time in the given data, the % data appears highly skewed. PID 26 & 27 have same usage time hence, the lines overlap in the graph, while PID 21 is somewhat different. If all the PIDs have finite and different usage times, then it would produce graph similar to what you have shown.
Igenyar
Igenyar 2023년 4월 4일
Exactly what I want, thank you so much for the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by