认识grep -e, tr, xargs
来源:互联网 发布:淘宝交易货款延期延长 编辑:程序博客网 时间:2024/06/05 19:53
今天浏览shell代码发现了下面一行代码:
hey -m PUT -n 850 -d value=`head -c $keysize < /dev/zero | tr '\0' '\141'` -c 85 -T application/x-www-form-urlencoded $i/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo &
从代码看,是对程序hey的结果进行格式化,下面看看是如何做的。
首先看看hey程序的结果:
$ hey -n 25600 -c 256 http://10.1.226.203:2379/v2/keys/foo
Summary:
Total: 0.5229 secs
Slowest: 0.0638 secs
Fastest: 0.0001 secs
Average: 0.0049 secs
Requests/sec: 48957.8739
Total data: 8934400 bytes
Size/request: 349 bytes
Detailed Report:
DNS+dialup:
Average: 0.0001 secs
Fastest: 0.0000 secs
Slowest: 0.0428 secs
DNS-lookup:
Average: 0.0000 secs
Fastest: 0.0000 secs
Slowest: 0.0000 secs
Request Write:
Average: 0.0001 secs
Fastest: 0.0000 secs
Slowest: 0.0213 secs
Response Wait:
Average: 0.0038 secs
Fastest: 0.0001 secs
Slowest: 0.0190 secs
Response Read:
Average: 0.0009 secs
Fastest: 0.0000 secs
Slowest: 0.0366 secs
Status code distribution:
[200] 25600 responses
Response time histogram:
0.000 [1] |
0.007 [19621] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
0.013 [5310] |∎∎∎∎∎∎∎∎∎∎∎
0.019 [440] |∎
0.026 [64] |
0.032 [31] |
0.038 [41] |
0.045 [53] |
0.051 [9] |
0.057 [22] |
0.064 [8] |
Latency distribution:
10% in 0.0015 secs
25% in 0.0025 secs
50% in 0.0038 secs
75% in 0.0062 secs
90% in 0.0097 secs
95% in 0.0114 secs
99% in 0.0176 secs
$
再看看执行grep -e执行后的结果:
$ hey -n 25600 -c 256 http://10.1.226.203:2379/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%"
Requests/sec: 47604.4368
Latency distribution:
90% in 0.0103 secs
$
原来grep命令里 -e 选项具有筛选多个字段的功能。
再看执行tr命令后的结果:
[david@localhost3 etcd]$ hey -n 25600 -c 256 http://10.1.226.203:2379/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t"
Requests/sec: 48666.5181Latency distribution: 90% in 0.0095 secs[david@localhost3 etcd]$
[david@localhost3 etcd]$
原来tr命令的功能是 :替换
把所有的"\n" 替换为 "\t"
hey -m PUT -n 850 -d value=`head -c $keysize < /dev/zero | tr '\0' '\141'` -c 85 -T application/x-www-form-urlencoded $i/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t" | xargs echo &
从代码看,是对程序hey的结果进行格式化,下面看看是如何做的。
首先看看hey程序的结果:
$ hey -n 25600 -c 256 http://10.1.226.203:2379/v2/keys/foo
Summary:
Total: 0.5229 secs
Slowest: 0.0638 secs
Fastest: 0.0001 secs
Average: 0.0049 secs
Requests/sec: 48957.8739
Total data: 8934400 bytes
Size/request: 349 bytes
Detailed Report:
DNS+dialup:
Average: 0.0001 secs
Fastest: 0.0000 secs
Slowest: 0.0428 secs
DNS-lookup:
Average: 0.0000 secs
Fastest: 0.0000 secs
Slowest: 0.0000 secs
Request Write:
Average: 0.0001 secs
Fastest: 0.0000 secs
Slowest: 0.0213 secs
Response Wait:
Average: 0.0038 secs
Fastest: 0.0001 secs
Slowest: 0.0190 secs
Response Read:
Average: 0.0009 secs
Fastest: 0.0000 secs
Slowest: 0.0366 secs
Status code distribution:
[200] 25600 responses
Response time histogram:
0.000 [1] |
0.007 [19621] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
0.013 [5310] |∎∎∎∎∎∎∎∎∎∎∎
0.019 [440] |∎
0.026 [64] |
0.032 [31] |
0.038 [41] |
0.045 [53] |
0.051 [9] |
0.057 [22] |
0.064 [8] |
Latency distribution:
10% in 0.0015 secs
25% in 0.0025 secs
50% in 0.0038 secs
75% in 0.0062 secs
90% in 0.0097 secs
95% in 0.0114 secs
99% in 0.0176 secs
$
再看看执行grep -e执行后的结果:
$ hey -n 25600 -c 256 http://10.1.226.203:2379/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%"
Requests/sec: 47604.4368
Latency distribution:
90% in 0.0103 secs
$
原来grep命令里 -e 选项具有筛选多个字段的功能。
再看执行tr命令后的结果:
[david@localhost3 etcd]$ hey -n 25600 -c 256 http://10.1.226.203:2379/v2/keys/foo | grep -e "Requests/sec" -e "Latency" -e "90%" | tr "\n" "\t"
Requests/sec: 48666.5181Latency distribution: 90% in 0.0095 secs[david@localhost3 etcd]$
[david@localhost3 etcd]$
原来tr命令的功能是 :替换
把所有的"\n" 替换为 "\t"
然后使用xargs把替换后的字符串打印出来。
阅读全文
0 0
- 认识grep -e, tr, xargs
- shell——cat,find,xargs,tr,sort,grep
- Linux管线命令 - cut,grep,sort,uniq,wc,tee,tr,col,join,paste,expand,split,xargs
- 几个常用的文本处理shell 命令:find、grep、xargs、sort、uniq、tr、cut、paste、wc、sed、awk
- 几个常用的文本处理shell 命令:find、grep、xargs、sort、uniq、tr、cut、paste、wc、sed、awk
- find xargs grep ...
- linux grep xargs
- grep 、find、xargs使用方法
- find |xargs |grep命令
- xargs 与 tr, sort uniq
- find xargs grep 查找技巧
- alias、grep、wc、find、xargs
- linux 的 find,xargs,grep
- xargs和grep的区别
- find、xargs、grep基本用法
- SHELL [正则表达式][grep][tr]
- tr、wc、uniq、grep、diff
- find、grep、xargs命令的结合使用
- 使用shader效果
- Java8 新特性
- Linux Kernel 学习笔记13:混杂设备模型
- didn't find class on path dexpathlist错误解决办法
- 10391
- 认识grep -e, tr, xargs
- dubbo 4 服务消费者到提供者过程
- 动态规划——最长上升子序列
- iOS常见加密方式
- 基于结巴分词的基础中文词语去歧实现
- windows环境下Tensorflow的安装
- 算法导论红黑树实现
- Java小项目之GUI界面动态图的移动
- UnityShader入门精要学习笔记(一):渲染流水线