0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

親切なtimeといえばhyperfine

Posted at

メリークリスマス!開発環境を紹介します Advent Calendar 2024です。

今日も今日とて隙間産業。
本日紹介するのは、前回ripgrepを紹介したときにベンチマークをとったhyperfineです。

hyperfine

hyperfineはRust製のコマンドラインベンチマークツールです。
言うならば、Rustで現代風に再実装されたtimeコマンドです。

メジャーなtimeコマンドに比べて、以下のような利点があります。
とりあえずコマンドを叩けば十分な結果を出してくれる親切さが良いです。

  • デフォルトでほどよいN回を推定し実行してくれる
  • 実行中の視覚的フィードバック
  • シグマのような統計値も出してくれる
  • 数値に問題があると改善案を警告で提案してくれる
    • 結果が速すぎて正確な値じゃないかもしれない、とか
    • 最初の数値だけ遅いとwarmupをしないか、とか
  • 様々な出力形式に対応

実行例

前回の記事で行った、grepとripgrepの比較の様子です。
実行中にプログレスバーが出てわかりやすいですね。

output.gif

上記gifの最後に出ている結果はこんな感じ。

image.png

  • それぞれ10回実行され、統計値(σ、max、min)を出してくれる
  • 初回実行が遅いと警告を出し、以下をお勧めしている
    • --warmupオプションによる実行前にN回のウォームアップ
    • --prepareオプションによるキャッシュクリアコマンドの指定
  • コマンドを2つ入力すると、比較結果を出してくれる

まとめ

hyperfineの紹介でした。
timeの代わりに親切なhyperfineを使おう!

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?