我们可以查看fork/s和exec/s列的值,看看系统是否在创建大量新的进程 。
利用time命令测试某个命令和程序的执行效率
我们可以利用time命令来测试一个命令的执行效率,语法为:
time command
command is executed. Upon completion, time prints the elapsed time during the command, the time spent in the system, and the time spent executing the command. Times are reported in seconds.
Execution time can depend on the performance of the memory in which the program is running.
当我们觉得某个进程的性能不好时,最简单的方法就是利用time命令来查看一下进程执行时它的 时间分布情况,然后再用其他工具进一步分析 。
利用top命令查看最耗CPU资源的进程
我们可以利用top命令来查看最耗CPU资源的进程 。top命令还会根据进程占用CPU资源的多少而动态改变 。
它的语法为:
top [-s time] [-d count] [-q] [-u] [-h] [-n number]
其中各选项的含义为:
-s time: 屏幕刷新的时间间隔time,缺省为5秒;
-d count: 屏幕刷新count次后,top命令自己也退出;
-q: This option runs the top program at the same priority as if it is executed via a nice -20 command so that it will execute faster (see nice(1)). This can be very useful in discovering any system problem when the system is very sluggish. This option is accessibly only to users who have appropriate privileges.
-u: User ID (uid) numbers are displayed instead of usernames. This improves execution speed by eliminating the additional time required to map uid numbers to user names.
-h: Hides the individual CPU state information for systems having multiple processors. Only the average CPU status will be displayed.
-n number: Show only number processes per screen. Note that this option is ignored if number is greater than the maximum number of processes that can be displayed per screen.
在top命令运行时,我们可用以下几个快捷键来翻屏:
j: 向前翻;
k: 向后翻;
t: 回到第一页;
对结果的分析:
通过top命令,我们可以快速了解到目前系统的CPU资源使用情况,尤其是占用CPU资源最多的进程是我们必须关注的对象 。
我们通过RES(the current size of the process resident in memory)列可以知道每个进程占用内存的数量 。
我们通过NICE列可以知道系统是否使用NICE值来调节该进程的工作负载平衡 。
利用uptime命令查看系统整体情况
uptime prints the current time, the length of time the system has been up, the number of users logged on to the system, and the average number of jobs in the run queue over the last 1, 5, and 15 minutes.
w is linked to uptime and prints the same output as uptime -w, displaying a summary of the current activity on the system.
它的语法为:
uptime [-hlsuw] [user]
w [-hlsuw] [user]
其中各选项的含义为:
-h: Suppress the first line and the heading line. This option should not be used with the -u option. This option assumes the use of the -w option to uptime.
-l: Use long output. This option assumes the use of the -w option to uptime.
-s: Use the short form of output for displaying terminal information. The terminal name is abbreviated; the login time and CPU times are suppressed.
-u: Print only the first line describing the overall state of the system. This is the default for the uptime command.ormation for systems having multiple processors. Only the average CPU status will be displayed.
-w: Print a summary of the current activity on the system for each user. This is the default for the w command.
利用GlancePlus分析系统CPU资源利用率
利用HP的GlancePlus工具可以对进程的整体情况和单独的某个进程都详细分析 。
1)对CPU的整体使用情况的分析:
推荐阅读
- 《暗黑破坏神4》将每三个月推出一次重大季度更新
- 日本实体月榜:任天堂Switch三月重登游戏机销量榜首
- 直接引用句什么意思
- 二 性能调试---性能分析工具
- 五 性能调试---I/O性能分析
- 谣言的经典语录
- 秋粮作物重点防控这三类虫害
- 三宝汤是哪三宝
- 产品持续热销索爱第三季度增长势头迅猛
- 大年初三又被称为什么
