How can I use the data stream in htop to build a analysis chart?

Asked by Haodong Wang on 2020-02-10

I want to compare the CPU usage of different softwares in a certain time , but counting by eyes is not accuracy

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu htop Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
2020-02-11
Last query:
2020-02-11
Last reply:
2020-02-11

You can use the sleep command to wait some time in a script. Eh.

#!/bin/bash
echo "before"
sleep 5
echo "5 seconds later"

And so on. Does that help?

Manfred Hampl (m-hampl) said : #2

Have you considered using the command "time" instead of "htop"?

Haodong Wang (sparta121) said : #3

Thanks your help , andrew . I know your mean is to write a shell which sleep per certain time to record . Even through now I don not know how to grab data from htop , this dynamic window. Maybe I need read some tutorial beyond htop.

Thanks you , m-hampl. I check command 'time' and it does provide the function which show the runtime of a program . But in my case , the program is working for a while so its needless to compare start time . Anyway thank you!

Haodong Wang (sparta121) said : #5

Oh that is it! Thank you!

Haodong Wang (sparta121) said : #6

Thanks actionparsnip, that solved my question.