{"id":176245,"date":"2020-04-20T10:39:17","date_gmt":"2020-04-20T02:39:17","guid":{"rendered":"https:\/\/gulass.cn\/?p=176245"},"modified":"2020-04-07T09:41:27","modified_gmt":"2020-04-07T01:41:27","slug":"linux-command-runtime-test","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-command-runtime-test.html","title":{"rendered":"Linux\u547d\u4ee4\u8fd0\u884c\u65f6\u95f4\u6d4b\u8bd5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u5de5\u4f5c\u4e2d\uff0c\u6211\u66fe\u5199\u8fc7\u4e00\u4e2a Shell \u811a\u672c\uff0c\u8fd9\u4e2a\u811a\u672c\u53ef\u4ee5\u4ece 4 \u4e2a NTP \u670d\u52a1\u5668\u8f6e\u6d41\u83b7\u53d6\u65f6\u95f4\uff0c\u7136\u540e\u5c06\u6700\u53ef\u9760\u7684\u65f6\u95f4\u8bbe\u7f6e\u4e3a\u7cfb\u7edf\u65f6\u95f4\u3002\u56e0\u4e3a\u6211\u4eec\u5bf9\u4e8e\u65f6\u95f4\u7684\u8981\u6c42\u6bd4\u8f83\u9ad8\uff0c\u9700\u8981\u5728\u77ed\u65f6\u95f4\u5185\u5c31\u83b7\u53d6\u5230\u6b63\u786e\u7684\u65f6\u95f4\u3002\u6240\u4ee5\u6211\u4eec\u5c31\u9700\u8981\u5bf9\u8fd9\u4e2a\u811a\u672c\u8fd0\u884c\u65f6\u95f4\u8fdb\u884c\u6d4b\u8bd5\uff0c\u770b\u770b\u4ece\u5f00\u59cb\u8fd0\u884c\u5230\u6b63\u786e\u8bbe\u7f6e\u65f6\u95f4\u9700\u8981\u82b1\u8d39\u591a\u5c11\u65f6\u95f4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u5176\u5b9e\u5728\u5de5\u4f5c\u4e2d\uff0c\u8fd8\u6709\u5f88\u591a\u60c5\u51b5\u4e0b\u9700\u8981\u6d4b\u8bd5\u4e00\u4e2a\u811a\u672c\u6216\u8005\u7a0b\u5e8f\u8fd0\u884c\u591a\u5c11\u65f6\u95f4\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u65f6\u95f4\u6027\u8981\u6c42\u6bd4\u8f83\u9ad8\u7684\u7cfb\u7edf\u66f4\u662f\u5982\u6b64\u3002\u5bf9\u4e8e\u65f6\u95f4\u7684\u6d4b\u8bd5\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u5230\u4e00\u4e2a\u547d\u4ee4\uff1atime \u3002\u4e0b\u9762\u6211\u4eec\u5c31\u8be6\u7ec6\u770b\u770b\u5982\u4f55\u4f7f\u7528 time \u547d\u4ee4\u6765\u5bf9\u811a\u672c\/\u547d\u4ee4\u8fdb\u884c\u6d4b\u65f6\u3002<\/p>\n

1. time \u547d\u4ee4\u57fa\u672c\u7528\u6cd5<\/strong><\/div>\n

time \u547d\u4ee4\u6700\u57fa\u672c\u7684\u7528\u6cd5\uff0c\u5c31\u662f time + \u547d\u4ee4 \uff0c\u6bd4\u5982\uff1a<\/p>\n

$ time ping baidu.com \r\nPING baidu.com (123.125.114.144) 56(84) bytes of data. \r\n64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=1 ttl=56 time=2.83 ms \r\n64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=2 ttl=56 time=2.77 ms \r\n\u2026\u2026\u2026\u2026 \r\n^C \r\n--- baidu.com ping statistics --- \r\n8 packets transmitted, 8 received, 0% packet loss, time 10818ms \r\nrtt min\/avg\/max\/mdev = 2.765\/2.808\/2.862\/0.039 ms \r\n \r\nreal    0m11.173s \r\nuser    0m0.004s \r\nsys     0m0.002s \r\n<\/pre>\n

\u5728\u7ed3\u679c\u91cc\uff0creal \u8868\u793a\u4ece\u6211\u4eec\u6267\u884c ping \u547d\u4ee4\u5230\u6700\u7ec8\u6309 ctrl+c \u7ec8\u6b62\u8fd9\u6bb5\u65f6\u95f4\u6240\u8017\u8d39\u7684\u65f6\u95f4;user \u53ca sys \u5206\u522b\u8868\u793a ping \u547d\u4ee4\u5728\u7528\u6237\u7a7a\u95f4\u53ca\u5185\u6838\u7a7a\u95f4\u6240\u8fd0\u884c\u7684\u65f6\u95f4\u3002<\/p>\n

2. \u5c06\u65f6\u95f4\u4fe1\u606f\u5199\u5165\u6587\u4ef6<\/strong><\/div>\n

\u5982\u679c\u6211\u4eec\u60f3\u628a\u65f6\u95f4\u4fe1\u606f\u76f4\u63a5\u5199\u5165\u5230\u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 -o \u9009\u9879\uff0c\u5e76\u6307\u5b9a\u5199\u5165\u7684\u6587\u4ef6\u8def\u5f84\u3002<\/p>\n

$ \/usr\/bin\/time -o \/home\/alvin\/time-output.txt ping baidu.com<\/pre>\n

\u6267\u884c\u8fd9\u4e2a\u547d\u4ee4\u540e\uff0cping \u547d\u4ee4\u7684\u8f93\u51fa\u7ed3\u679c\u4f9d\u7136\u4f1a\u5728\u7ec8\u7aef\u91cc\uff0c\u800c time \u547d\u4ee4\u7684\u7ed3\u679c\u5c31\u5199\u5165\u5230\u6211\u4eec\u6240\u6307\u5b9a\u7684 time-output.txt \u6587\u4ef6\u91cc\u3002<\/p>\n

-o \u9009\u9879\u8868\u793a\u8f93\u51fa\u6587\u4ef6\u4e0d\u5b58\u5728\u5c31\u521b\u5efa\uff0c\u5982\u679c\u5b58\u5728\u7684\u8bdd\u5c31\u76f4\u63a5\u8986\u76d6\u91cd\u5199\u3002\u5982\u679c\u6211\u4eec\u4e0d\u60f3\u8986\u76d6\u91cd\u5199\uff0c\u800c\u662f\u60f3\u8ffd\u52a0\u5728\u6587\u4ef6\u540e\u9762\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 -a \u9009\u9879\u3002<\/p>\n

$ \/usr\/bin\/time -a \/home\/smart\/time-output.txt ping linoxide.com<\/pre>\n
3. \u663e\u793a\u66f4\u8be6\u7ec6\u7684\u65f6\u95f4\u4fe1\u606f<\/strong><\/div>\n

time \u547d\u4ee4\u4e0d\u5e26\u9009\u9879\u7684\u8bdd\uff0c\u663e\u793a\u7684\u4fe1\u606f\u91cf\u6bd4\u8f83\u5c11\uff0c\u5982\u679c\u6211\u4eec\u60f3\u83b7\u5f97\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 -v \u9009\u9879\u3002<\/p>\n

$ \/usr\/bin\/time -v ping baidu.com \r\nPING baidu.com (123.125.114.144) 56(84) bytes of data. \r\n64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=1 ttl=56 time=2.75 ms \r\n64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=2 ttl=56 time=2.76 ms \r\n64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=3 ttl=56 time=2.85 ms \r\n64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=4 ttl=56 time=2.77 ms \r\n^C \r\n--- baidu.com ping statistics --- \r\n4 packets transmitted, 4 received, 0% packet loss, time 3300ms \r\nrtt min\/avg\/max\/mdev = 2.751\/2.785\/2.851\/0.075 ms \r\n        Command being timed: \"ping baidu.com\" \r\n        User time (seconds): 0.00 \r\n        System time (seconds): 0.00 \r\n        Percent of CPU this job got: 0% \r\n        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.64 \r\n        Average shared text size (kbytes): 0 \r\n        Average unshared data size (kbytes): 0 \r\n        Average stack size (kbytes): 0 \r\n        Average total size (kbytes): 0 \r\n        Maximum resident set size (kbytes): 2140 \r\n        Average resident set size (kbytes): 0 \r\n        Major (requiring I\/O) page faults: 0 \r\n        Minor (reclaiming a frame) page faults: 626 \r\n        Voluntary context switches: 10 \r\n        Involuntary context switches: 0 \r\n        Swaps: 0 \r\n        File system inputs: 0 \r\n        File system outputs: 0 \r\n        Socket messages sent: 0 \r\n        Socket messages received: 0 \r\n        Signals delivered: 0 \r\n        Page size (bytes): 4096 \r\n        Exit status: 0 \r\n<\/pre>\n

\u8fd9\u4e2a\u7ed3\u679c\u4fe1\u606f\u5c31\u76f8\u5f53\u8be6\u7ec6\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5\u83b7\u53d6\u5230\u8db3\u591f\u591a\u6211\u4eec\u6240\u9700\u8981\u7684\u4fe1\u606f\u3002<\/p>\n

4. \u81ea\u5b9a\u4e49\u8f93\u51fa\u683c\u5f0f<\/strong><\/div>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0ctime \u547d\u4ee4\u53ea\u8f93\u51fa real\uff0cusr\uff0csys \u4e09\u4e2a\u5185\u5bb9\uff0c\u5982\u679c\u6211\u4eec\u60f3\u8981\u4e2a\u6027\u5316\u4e00\u4e9b\uff0c\u7b97\u5b9a\u4e49\u5b83\u7684\u8f93\u51fa\u683c\u5f0f\uff0ctime \u547d\u4ee4\u4e5f\u662f\u652f\u6301\u7684\u3002time \u547d\u4ee4\u652f\u6301\u7684\u683c\u5f0f\u6709\u5f88\u591a\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

C - Name and command line arguments used \r\nD - Average size of the process's unshared data area in kilobytes \r\nE - Elapsed time in a clock format \r\nF - Number of page faults \r\nI - Number of file system inputs by the process \r\nK - Average total memory use of the process in kilobytes \r\nM - Maximum resident set the size of the process during the lifetime in Kilobytes \r\nO - Number of file system outputs by the process \r\nP - Percentage of CPU that the job received \r\nR - Number of minor or recoverable page faults \r\nS - Total number of CPU seconds used by the system in kernel mode \r\nU - Total number of CPU seconds used by user mode \r\nW - Number of times the process was swapped out of main memory \r\nX - Average amount of shared text in the process \r\nZ - System's page size in kilobytes \r\nc - Number of times the process was context-switched \r\ne - Elapsed real time used by the process in seconds \r\nk - Number of signals delivered to the process \r\np - Average unshared stack size of the process in kilobytes \r\nr - Number of socket messages received by the process \r\ns - Number of socket messages sent by the process \r\nt - Average resident set size of the process in kilobytes \r\nw - Number of time the process was context-switched voluntarily \r\nx - Exit status of the command \r\n<\/pre>\n

\u5982\u679c\u6211\u4eec\u60f3\u8981\u8f93\u51fa\u4ee5\u4e0b\u8fd9\u6837\u7684\u683c\u5f0f\uff1a<\/p>\n

Elapsed Time = 0:01:00, Inputs 2, Outputs 1\r\n<\/pre>\n

\u6211\u4eec\u53ef\u4ee5\u8fd9\u6837\u81ea\u5b9a\u4e49\uff1a<\/p>\n

$ \/usr\/bin\/time -f \"Elapsed Time = %E, Inputs %I, Outputs %O\" ping baidu.com \r\nPING baidu.com (220.181.38.148) 56(84) bytes of data. \r\n64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=54 time=1.82 ms \r\n64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=54 time=1.86 ms \r\n^C \r\n--- baidu.com ping statistics --- \r\n4 packets transmitted, 4 received, 0% packet loss, time 3003ms \r\nrtt min\/avg\/max\/mdev = 1.825\/1.859\/1.879\/0.056 ms \r\nElapsed Time = 0:03.92, Inputs 0, Outputs 0\r\n<\/pre>\n

\u5982\u679c\u4f60\u60f3\u8ba9\u8f93\u51fa\u7684\u7ed3\u679c\u6709\u6362\u884c\uff0c\u53ef\u4ee5\u5728\u5bf9\u5e94\u7684\u5730\u65b9\u6dfb\u52a0 \\n \uff0c\u6bd4\u5982\uff1a<\/p>\n

$ \/usr\/bin\/time -f \"Elapsed Time = %E \\n Inputs %I \\n Outputs %O\" ping baidu.com<\/pre>\n

\u8fd9\u6837\u8f93\u51fa\u7684\u7ed3\u679c\u5c31\u7c7b\u4f3c\u4e8e\u8fd9\u6837\uff1a<\/p>\n

Elapsed Time = 0:03.92 \r\nInputs 0 \r\nOutputs 0 \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u5176\u5b9e\u5728\u5de5\u4f5c\u4e2d\uff0c\u8fd8\u6709\u5f88\u591a\u60c5\u51b5\u4e0b\u9700\u8981\u6d4b\u8bd5\u4e00\u4e2a\u811a\u672c\u6216\u8005\u7a0b\u5e8f\u8fd0\u884c\u591a\u5c11\u65f6\u95f4\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u65f6\u95f4\u6027\u8981\u6c42\u6bd4\u8f83\u9ad8\u7684\u7cfb\u7edf\u66f4\u662f\u5982\u6b64\u3002\u5bf9 […]<\/p>\n","protected":false},"author":1329,"featured_media":176247,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-176245","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/176245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=176245"}],"version-history":[{"count":1,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/176245\/revisions"}],"predecessor-version":[{"id":176248,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/176245\/revisions\/176248"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/176247"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=176245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=176245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=176245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}