Bencher Auto-Hébergé avec Docker Démarrage Rapide
Qu’est-ce que Bencher ?
Bencher est une suite d’outils de benchmarking continu. Avez-vous déjà eu une régression de performance qui a impacté vos utilisateurs ? Bencher aurait pu empêcher cela de se produire. Bencher vous permet de détecter et de prévenir les régressions de performance avant qu’elles n’arrivent en production.
- Exécuter: Exécutez vos benchmarks localement ou en CI en utilisant vos outils de benchmarking préférés. La CLI
bencher
enveloppe simplement votre harnais de benchmarking existant et stocke ses résultats. - Suivre: Suivez les résultats de vos benchmarks au fil du temps. Surveillez, interrogez et graphiquez les résultats à l’aide de la console web Bencher en fonction de la branche source, du banc d’essai et de la mesure.
- Détecter: Détectez les régressions de performances en CI. Bencher utilise des analyses de pointe et personnalisables pour détecter les régressions de performances avant qu’elles n’arrivent en production.
Pour les mêmes raisons que les tests unitaires sont exécutés en CI pour prévenir les régressions de fonctionnalités, les benchmarks devraient être exécutés en CI avec Bencher pour prévenir les régressions de performance. Les bugs de performance sont des bugs !
Bencher Auto-hébergé
Bencher est open source et auto-hébergeable. Si vous êtes intéressé par l’utilisation de Bencher Cloud, consultez le tutoriel de démarrage rapide de Bencher Cloud. Ce tutoriel vous expliquera comment configurer Bencher Auto-hébergé avec Docker.
🐰 Une fois que vous vous sentez à l’aise avec l’utilisation de Bencher Auto-hébergé, envisagez de consulter les ressources suivantes :
Installer Docker
Pour exécuter les serveurs Console et API dans ce tutoriel, vous devrez avoir docker
installé.
Vérifiez si vous avez docker
installé. Exécutez :
docker --version
docker --version
docker --version
docker --version
Vous devriez voir quelque chose comme :
Docker version 20.10.17, build 100c701
Il est acceptable que votre numéro de version soit différent. Il est simplement important que cette commande fonctionne.
Sinon, suivez les instructions pour installer docker
.
Installer le CLI bencher
Sélectionnez votre système d’exploitation et exécutez la commande fournie pour installer le CLI bencher
.
Pour plus de détails, consultez la documentation sur l’installation du CLI bencher
.
⠀
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"
⠀
Maintenant, vérifions que vous avez le CLI bencher
installé. Exécutez :
bencher --version
bencher --version
bencher --version
bencher --version
Vous devriez voir :
bencher 0.5.0
Exécutez bencher up
Avec docker
et le CLI bencher
installés, vous pouvez maintenant exécuter les serveurs Console et API avec la sous-commande CLI bencher up
. Exécutez :
bencher up
bencher up
bencher up
bencher up
Vous devriez voir quelque chose comme :
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...
Encore une fois, il est normal que votre sortie soit différente. L’important est que cette commande fonctionne.
🐰 Si vous recevez une erreur de
ghcr.io
disant :"authentication required"
Essayez de lancer :docker logout ghcr.io
Sélectionnez votre boîte à outils de benchmark
Si vous avez déjà des benchmarks écrits, sélectionnez votre langage de programmation et votre boîte à outils de benchmark dans la liste ci-dessous. Sinon, passez simplement cette étape. Pour plus de détails, consultez les adaptateurs de boîte à outils de benchmark documentation.
Suivre vos Benchmarks
Vous êtes maintenant prêt à suivre les résultats de vos benchmarks !
Pour ce faire, vous utiliserez la sous-commande CLI bencher run
pour exécuter vos benchmarks et collecter les résultats.
Exécutez :
⠀
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'"
Vous devrez peut-être modifier la commande de benchmark pour l’adapter à votre configuration.
Si vous n’avez pas encore de benchmarks, vous pouvez simplement utiliser la sous-commande bencher mock
comme votre commande de benchmark pour générer des données factices.
Si tout fonctionne comme prévu, la fin de la sortie devrait ressembler à ceci :
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
Vous pouvez maintenant visualiser les résultats de chacun de vos benchmarks dans le navigateur.
Cliquez ou copiez et collez les liens de View results
.
Pour revendiquer le projet, cliquez ou copiez et collez le lien Claim this project
dans votre navigateur.
🐰 Félicitations ! Vous avez suivi vos premiers résultats de benchmark avec Bencher en Auto-Hébergement ! 🎉