Dockerを使用したBencher セルフホスティング クイックスタート
Bencherとは?
Bencherは、連続ベンチマーキングツールのスイートです。 パフォーマンスの後退があなたのユーザーに影響を与えたことはありますか? Bencherなら、それが起こるのを防げた可能性があります。 Bencherは、パフォーマンスの低下を_productionに到達する_前に検出し、防止することを可能にします。
- 実行: お気に入りのベンチマーキングツールを使用してベンチマークをローカルまたはCIで実行します。
bencher
CLIは単にあなたの既存のベンチマークハーネスをラップし、その結果を保存します。 - 追跡: ベンチマークの結果を時間と共に追跡します。ソースブランチ、テストベッド、測定基準に基づいてBencherのWebコンソールを使用して結果を監視、クエリ、グラフ化します。
- キャッチ: CIでパフォーマンスの後退をキャッチします。Bencherは最先端のカスタマイズ可能な分析を使用して、パフォーマンスの後退がProductionに到達する前にそれを検出します。
機能の後退を防ぐためにユニットテストがCIで実行されるのと同じ理由で、Bencherを使用してCIでベンチマークを実行してパフォーマンスの後退を防ぐべきです。パフォーマンスのバグはバグです!
Bencher Self-Hosted
Bencherはオープンソースで、セルフホストが可能です。 Bencher Cloudの使用に興味がある場合は、Bencher Cloud クイックスタートチュートリアルをチェックしてください。 このチュートリアルでは、Dockerを使用してBencher Self-Hostedのセットアップを行います。
🐰 Bencher Self-Hostedの使用に慣れてきたら、以下のリソースをチェックしてみてください:
Dockerのインストール
このチュートリアルでコンソールとAPIサーバーを実行するには、docker
がインストールされている必要があります。
docker
がインストールされているか確認してください。次を実行します:
docker --version
docker --version
docker --version
docker --version
次のような出力が表示されるはずです:
Docker version 20.10.17, build 100c701
バージョン番号が異なっていても問題ありません。重要なのは、このコマンドが動作することです。
もし動作しない場合はdocker
のインストール手順に従ってください。
bencher
CLI をインストールする
あなたのオペレーティングシステムを選択し、提供されるコマンドを実行して bencher
CLI をインストールします。
詳細は、bencher
CLI のインストールドキュメントを参照してください。
⠀
curl --proto '=https' --tlsv1.2 -sSfL https://bencher.dev/download/install-cli.sh | sh
curl --proto '=https' --tlsv1.2 -sSfL https://bencher.dev/download/install-cli.sh | sh
cargo install --git https://github.com/bencherdev/bencher --branch main --locked --force bencher_cli
powershell -c "irm https://bencher.dev/download/install-cli.ps1 | iex"
⠀
次に、bencher
CLI がインストールされているか確認しましょう。以下を実行します:
bencher --version
bencher --version
bencher --version
bencher --version
次のように表示されるはずです:
bencher 0.5.0
bencher up
を実行する
docker
と bencher
CLI がインストールされている状態で、 bencher up
CLI サブコマンド を使用して Console と API サーバーを実行できます。
次のコマンドを実行してください:
bencher up
bencher up
bencher up
bencher up
次のような出力が表示されるはずです:
Pulling `ghcr.io/bencherdev/bencher-api:latest` image...Creating `bencher_api` container...Starting `bencher_api` container...
Pulling `ghcr.io/bencherdev/bencher-console:latest` image...Creating `bencher_console` container...Starting `bencher_console` container...
🐰 Bencher Self-Hosted is up and running!Console Server: http://localhost:3000API Server: http://localhost:61016
Press Ctrl+C to stop Bencher Self-Hosted.
🐰 Bencher Self-Hosted logs...
Jan 08 16:49:07.727 INFO 🐰 Bencher API Server v0.5.0...
再度、出力が異なっていても問題ありません。このコマンドが機能することが重要です。
🐰
ghcr.io
から"authentication required"
というエラーが表示される場合:docker logout ghcr.io
を実行してみてください
ベンチマークハーネスを選択
すでにベンチマークが書かれている場合は、以下のリストからプログラミング言語とベンチマークハーネスを選択してください。そうでない場合は、このステップをスキップしてください。詳細については、ベンチマークハーネスアダプタ のドキュメントを参照してください。
ベンチマークを追跡する
ベンチマーク結果を追跡する準備が整いました!
これを行うには、ベンチマークを実行して結果を収集するためにbencher run
CLIサブコマンドを使用します。
実行します:
⠀
bencher run --host https://localhost:61016 "make benchmarks"
bencher run --host https://localhost:61016 "make benchmarks"
bencher run --host https://localhost:61016 "make benchmarks --benchmark_format=json"
bencher run --host https://localhost:61016 "make benchmarks --benchmark_format=json"
bencher run --host https://localhost:61016 "dotnet run -c Release"
bencher run --host https://localhost:61016 "dotnet run -c Release"
⠀
bencher run --host https://localhost:61016 "go test -bench"
bencher run --host https://localhost:61016 "go test -bench"
bencher run --host https://localhost:61016 --file results.json "java -jar benchmarks.jar -rf json -rff results.json"
bencher run --host https://localhost:61016 --file results.json "java -jar benchmarks.jar -rf json -rff results.json"
bencher run --host https://localhost:61016 "node benchmark.js"
bencher run --host https://localhost:61016 "node benchmark.js"
bencher run --host https://localhost:61016 "node benchmark.js"
bencher run --host https://localhost:61016 "node benchmark.js"
bencher run --host https://localhost:61016 "bencher mock"
bencher run --host https://localhost:61016 "bencher mock"
bencher run --host https://localhost:61016 "asv run"
bencher run --host https://localhost:61016 "asv run"
bencher run --host https://localhost:61016 --file results.json "pytest --benchmark-json results.json benchmarks.py"
bencher run --host https://localhost:61016 --file results.json "pytest --benchmark-json results.json benchmarks.py"
bencher run --host https://localhost:61016 "ruby benchmarks.rb"
bencher run --host https://localhost:61016 "ruby benchmarks.rb"
bencher run --host https://localhost:61016 "cargo +nightly bench"
bencher run --host https://localhost:61016 "cargo +nightly bench"
bencher run --host https://localhost:61016 "cargo bench"
bencher run --host https://localhost:61016 "cargo bench"
bencher run --host https://localhost:61016 "cargo bench"
bencher run --host https://localhost:61016 "cargo bench"
bencher run --host https://localhost:61016 "cargo bench"
bencher run --host https://localhost:61016 "cargo bench"
bencher run --host https://localhost:61016 --file results.json "hyperfine --export-json results.json 'sleep 0.1'"
bencher run --host https://localhost:61016 --file results.json "hyperfine --export-json results.json 'sleep 0.1'"
ベンチマークコマンドを設定に合わせて変更する必要があるかもしれません。
まだベンチマークがない場合は、ベンチマークコマンドとしてbencher mock
サブコマンドを使用してモックデータを生成できます。
すべてが予期通りに動作する場合、出力の最後は次のようになります:
View results:- bencher::mock_0 (Latency): https://localhost:3000/perf/project-abc4567-wxyz123456789?branches=88d5192d-5cd1-47c6-a817-056e5968737c&heads=657a8ee9-1f30-49d4-bd9b-ceed02576d7e&testbeds=f3a5db46-a57e-4caf-b96e-f0c1111eaa67&benchmarks=f7022024-ae16-4782-8f0d-869d65a82930&measures=775999d3-d705-482f-acd8-41947f8e0fbc&start_time=1741390156000&end_time=1743982156000&report=709d3476-51a4-4939-9584-75d9a2c04c54- bencher::mock_1 (Latency): https://localhost:3000/perf/project-abc4567-wxyz123456789?branches=88d5192d-5cd1-47c6-a817-056e5968737c&heads=657a8ee9-1f30-49d4-bd9b-ceed02576d7e&testbeds=f3a5db46-a57e-4caf-b96e-f0c1111eaa67&benchmarks=7a823440-216f-482d-a05f-8bf75e865bba&measures=775999d3-d705-482f-acd8-41947f8e0fbc&start_time=1741390156000&end_time=1743982156000&report=709d3476-51a4-4939-9584-75d9a2c04c54- bencher::mock_2 (Latency): https://localhost:3000/perf/project-abc4567-wxyz123456789?branches=88d5192d-5cd1-47c6-a817-056e5968737c&heads=657a8ee9-1f30-49d4-bd9b-ceed02576d7e&testbeds=f3a5db46-a57e-4caf-b96e-f0c1111eaa67&benchmarks=8d9695ff-f352-4781-9561-3c69012fd9fe&measures=775999d3-d705-482f-acd8-41947f8e0fbc&start_time=1741390156000&end_time=1743982156000&report=709d3476-51a4-4939-9584-75d9a2c04c54- bencher::mock_3 (Latency): https://localhost:3000/perf/project-abc4567-wxyz123456789?branches=88d5192d-5cd1-47c6-a817-056e5968737c&heads=657a8ee9-1f30-49d4-bd9b-ceed02576d7e&testbeds=f3a5db46-a57e-4caf-b96e-f0c1111eaa67&benchmarks=8ef6e256-8084-4afe-a7cf-eaa46384c19d&measures=775999d3-d705-482f-acd8-41947f8e0fbc&start_time=1741390156000&end_time=1743982156000&report=709d3476-51a4-4939-9584-75d9a2c04c54- bencher::mock_4 (Latency): https://localhost:3000/perf/project-abc4567-wxyz123456789?branches=88d5192d-5cd1-47c6-a817-056e5968737c&heads=657a8ee9-1f30-49d4-bd9b-ceed02576d7e&testbeds=f3a5db46-a57e-4caf-b96e-f0c1111eaa67&benchmarks=1205e35a-c73b-4ff9-916c-40838a62ae0b&measures=775999d3-d705-482f-acd8-41947f8e0fbc&start_time=1741390156000&end_time=1743982156000&report=709d3476-51a4-4939-9584-75d9a2c04c54
Claim this project: https://localhost:3000/auth/signup?claim=d4b0cd5a-8422-40af-9872-8e18d5d062c4
ブラウザで各ベンチマークの結果を確認できます。 「結果を表示」のリンクをクリックするか、コピーしてブラウザに貼り付けます。 プロジェクトを請求するには、「このプロジェクトを請求する」リンクをクリックするか、コピーしてブラウザに貼り付けます。
🐰 おめでとうございます!Bencher Self-Hostedで最初のベンチマーク結果を記録しました!🎉