diff options
author | huangzh <huangzh.bri@chinatelecom.cn> | 2018-11-07 11:45:38 +0800 |
---|---|---|
committer | huangzh <huangzh.bri@chinatelecom.cn> | 2018-11-08 10:57:13 +0800 |
commit | 1ff97d639e631fe7465038d76e093bc5c1a31867 (patch) | |
tree | d3f4aa2144043930c2fee7073a22e45a9f41805b /vcpe_beijing/vcpe/pressure/control.sh | |
parent | 4d96698b0cc2b738685482c8a8971f21b143b27e (diff) |
new add s3p test scripte
Change-Id: I84b933c017ad7cee12e70da868e8dea1dd9f348b
Issue-ID: INT-714
Signed-off-by: huangzh <huangzh.bri@chinatelecom.cn>
Diffstat (limited to 'vcpe_beijing/vcpe/pressure/control.sh')
-rw-r--r-- | vcpe_beijing/vcpe/pressure/control.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/vcpe_beijing/vcpe/pressure/control.sh b/vcpe_beijing/vcpe/pressure/control.sh new file mode 100644 index 0000000..65c9bc4 --- /dev/null +++ b/vcpe_beijing/vcpe/pressure/control.sh @@ -0,0 +1,25 @@ +#!/bin/bash +start_time=`date +%s` #定义脚本运行的开始时间 +[ -e /tmp/fd1 ] || mkfifo /tmp/fd1 #创建有名管道 +exec 3<>/tmp/fd1 #创建文件描述符,以可读(<)可写(>)的方式关联管道文件,这时候文件描述符3就有了有名管道文件的所有特性 +rm -rf /tmp/fd1 #关联后的文件描述符拥有管道文件的所有特性,所以这时候管道文件可以删除,我们留下文件描述符来用就可以了 +for ((i=1;i<=1000;i++)) +do + echo >&3 #&3代表引用文件描述符3,这条命令代表往管道里面放入了一个"令牌" +done + +for ((i=1;i<=10000;i++)) +do +read -u3 #代表从管道中读取一个令牌 +{ + echo 'success'$i & + echo >&3 #代表我这一次命令执行到最后,把令牌放回管道 +}& +done +wait + +stop_time=`date +%s` #定义脚本运行的结束时间 + +echo "TIME:`expr $stop_time - $start_time`" +exec 3<&- #关闭文件描述符的读 +exec 3>&- #关闭文件描述符的写 |