美文网首页
Linux统计时间的命令

Linux统计时间的命令

作者: wind_103 | 来源:发表于2020-12-28 21:26 被阅读0次

1、time

time ./clickhouse-client --query "INSERT INTO test.test_1w FORMAT CSVWithNames" </home/clickhouse/weibo.CSVWithNames

real    0m27.651suser    0m17.154ssys    0m4.828s

解析:1)实际时间(real time): 从command命令行开始执行到运行终止的消逝时间;

2)用户CPU时间(user CPU time): 命令执行完成花费的用户CPU时间,即命令在用户态中执行时间总和;

3)系统CPU时间(system CPU time): 命令执行完成花费的系统CPU时间,即命令在核心态中执行时间总和用户CPU时间和系统CPU时间之和为CPU时间,即命令占用CPU执行的时间总和。实际时间要大于CPU时间,因为Linux是多任务操作系统,往往在执行一条命令时,系统还要处理其它任务。

2、/usr/bin/time

使用/usr/bin/time  可以返回cpu的相关信息,加v可以看到详情

/usr/bin/time -v  ./clickhouse-client --query "INSERT INTO test.test_1w FORMAT CSVWithNames" </home/clickhouse/weibo.CSVWithNames

   Command being timed: "./clickhouse-client --query INSERT INTO test.test_1w FORMAT CSVWithNames"

   User time (seconds): 17.09

   System time (seconds): 3.57

   Percent of CPU this job got: 76%

   Elapsed (wall clock) time (h:mm:ss or m:ss): 0:26.87

   Average shared text size (kbytes): 0

   Average unshared data size (kbytes): 0

   Average stack size (kbytes): 0

   Average total size (kbytes): 0

   Maximum resident set size (kbytes): 1809068

   Average resident set size (kbytes): 0

   Major (requiring I/O) page faults: 0

   Minor (reclaiming a frame) page faults: 1569491

   Voluntary context switches: 94

   Involuntary context switches: 60

   Swaps: 0

   File system inputs: 0

   File system outputs: 0

   Socket messages sent: 0

   Socket messages received: 0

   Signals delivered: 0

   Page size (bytes): 4096

   Exit status: 0

%E real时间,显示格式为[小时:]分钟:秒

当需要后台执行时,最好使用 /usr/bin/time -f "time: %E" ,如果用time,会查不到real time

nohup /usr/bin/time -f "time: %E" ./clickhouse-client --connect_timeout 6000 --receive_timeout 6000 --send_timeout 6000 --query "insert into test.test_1w select * from default.abnormal limit 100000000;" &

相关文章

网友评论

      本文标题:Linux统计时间的命令

      本文链接:https://www.haomeiwen.com/subject/rftxoktx.html