gdu, gotty, fiber を試してみた。
こんにちは k-jun です。 今週も github で見つけたライブラリを調査していきます。
gdu
ディレクトリごとのディスクサイズを見れる du コマンドですが、これを interactive に実行できるようにしたもの。
du コマンドでファイルサイズが大きいディレクトリを見つける際に、-d 1
を付与してだんだん潜っていくのって結構めんどくさかったのでありがたいです。
brew install -f gdu
/.. 9.2 MiB [######### ] /objects 72.0 KiB [ ] /logs 56.0 KiB [ ] /hooks 48.0 KiB [ ] index 40.0 KiB [ ] /refs 8.0 KiB [ ] /info 4.0 KiB [ ] config 4.0 KiB [ ] ORIG_HEAD 4.0 KiB [ ] packed-refs 4.0 KiB [ ] HEAD 4.0 KiB [ ] FETCH_HEAD 4.0 KiB [ ] description 4.0 KiB [ ] COMMIT_EDITMSG
色も(伝わりませんが)綺麗ですし、いい感じです。縦移動と、ディレクトリを up するののショートカットはほしいところですが。
gotty
https://github.com/sorenisanerd/gotty
こちらもなかなかおもしろいですね。terminal で動作しているコマンドをブラウザで表示することができるもの。 以下のように打つことで<YOUR_COMMADN>の出力をブラウザ側で表示することができます。
gotty <YOUR_COMMAND>
default ではブラウザからの書き込みは受け付けていませんが、-w
を付与することでそれも可能になります。
gotty -w <YOUR_COMMAND>
ブラウザでなければならないケースというのもそこまで思いつきませんが面白いことは確かです。
fiber
https://github.com/gofiber/fiber
golang 系統の web フレームワークは多数存在しますが、その中でも最速を謳うものになります。(そんなものはいくらでもありそうですが) benchmarks を見てみるとたしかにそれなりに早そうです。 https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=plaintext&l=zijocf-sf
一応 gin と比べてみます。
package main import "github.com/gin-gonic/gin" func main() { r := gin.New() r.GET("/", func(c *gin.Context) { c.String(200, "Hello, World 👋!") }) r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") }
package main import "github.com/gofiber/fiber/v2" func main() { app := fiber.New() app.Get("/", func(c *fiber.Ctx) error { return c.SendString("Hello, World 👋!") }) app.Listen(":3000") }
vegeta でドーン!!
# gin ~/ghq(master ✗) echo "GET http://localhost:8080/" | vegeta attack -duration=5s -rate 2000 | vegeta report Requests [total, rate, throughput] 10000, 2000.20, 2000.16 Duration [total, attack, wait] 5s, 5s, 97.422µs Latencies [min, mean, 50, 90, 95, 99, max] 67.855µs, 138.304µs, 117.175µs, 192.795µs, 214.774µs, 275.153µs, 10.229ms Bytes In [total, mean] 180000, 18.00 Bytes Out [total, mean] 0, 0.00 Success [ratio] 100.00% Status Codes [code:count] 200:10000 Error Set:
# fiber ~ echo "GET http://localhost:3000/" | vegeta attack -duration=5s -rate 2000 | vegeta report Requests [total, rate, throughput] 10000, 2000.19, 2000.17 Duration [total, attack, wait] 5s, 5s, 64.773µs Latencies [min, mean, 50, 90, 95, 99, max] 54.56µs, 96.696µs, 87.147µs, 130.134µs, 157.834µs, 212.501µs, 2.517ms Bytes In [total, mean] 180000, 18.00 Bytes Out [total, mean] 0, 0.00 Success [ratio] 100.00% Status Codes [code:count] 200:10000 Error Set:
"Hello, World 👋!"を返すだけのかんたんな http サーバーなので、差は出にくいですが気持ち fiber のほうが早そうな...? golang で 小さいwebサーバーを作る & 性能が求められる場合には検討してみてもいいかもしれません。
ではでは、今日はこのへんで。