LoginSignup
14
5

More than 5 years have passed since last update.

任意のコマンドを N 回実行する ntimes 作った

Last updated at Posted at 2016-04-19

実は探せばあるんじゃないかと思いつつ。.
仕事中に欲しくなってとっさに作ったのでヘルプコマンドとかない雑な感じですが。

GitHub: yuya-takeyama/ntimes

インストール

GitHub のビルド済みのバイナリをあげています。
ダウンロードして適当にパスの通ったところにおいてください。

または Go をインストールしていれば go get でも大丈夫です。

$ go get github.com/yuya-takeyama/ntimes

使い方

$ ntimes 3 -- echo foo bar
foo bar
foo bar
foo bar

第一引数に繰り返し回数を指定し、-- の後に実行したいコマンド及びその引数を指定してください。

使用例: レスポンスタイムのパーセンタイル値を得る

ここでは curl と、以前紹介した percentile を組み合わせます。

$ ntimes 100 -- curl -s http://YOUR_URL/ -o /dev/null -w "%{time_starttransfer}\n" | percentile
50%:    0.51
66%:    0.541
75%:    0.578
80%:    0.604
90%:    0.668
95%:    0.793
98%:    1.515
99%:    1.673
100%:   1.842

URL は自分が管理しているサーバ等、他人に迷惑のかからないものにしてください。

14
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
5