Inicio Rápido de Bencher Autohospedado con Docker
¿Qué es Bencher?
Bencher es un conjunto de herramientas de benchmarking continuo. ¿Alguna vez has tenido un impacto de regresión de rendimiento en tus usuarios? Bencher podría haber evitado que eso sucediera. Bencher te permite detectar y prevenir las regresiones de rendimiento antes de que lleguen a producción.
- Ejecutar: Ejecute sus benchmarks localmente o en CI usando sus herramientas de benchmarking favoritas. La CLI
bencher
simplemente envuelve su arnés de benchmarks existente y almacena sus resultados. - Seguir: Sigue los resultados de tus benchmarks con el tiempo. Monitoriza, realiza consultas y representa gráficamente los resultados utilizando la consola web de Bencher basándose en la rama de origen, el banco de pruebas y la medida.
- Capturar: Captura las regresiones de rendimiento en CI. Bencher utiliza analíticas de vanguardia y personalizables para detectar regresiones de rendimiento antes de que lleguen a producción.
Por las mismas razones que las pruebas unitarias se ejecutan en CI para prevenir regresiones funcionales, los benchmarks deberían ejecutarse en CI con Bencher para prevenir regresiones de rendimiento. ¡Los errores de rendimiento son errores!
Bencher Autohospedado
Bencher es de código abierto y se puede hospedar por uno mismo. Si estás interesado en usar Bencher Cloud, consulta el tutorial de inicio rápido de Bencher Cloud. Este tutorial te guiará para configurarlo usando Bencher Autohospedado con Docker.
🐰 Una vez que te sientas cómodo usando Bencher Autohospedado, considera revisar los siguientes recursos:
Instalar Docker
Para ejecutar los servidores de consola y API en este tutorial, necesitarás tener docker
instalado. Comprueba si tienes docker
instalado. Ejecuta:
docker --version
docker --version
docker --version
docker --version
Deberías ver algo como:
Docker version 20.10.17, build 100c701
Está bien si tu número de versión es diferente. Es importante que este comando funcione. Si no es así, sigue las instrucciones para instalar docker
.
Instalar la CLI de bencher
Selecciona tu sistema operativo y ejecuta el comando proporcionado para instalar la CLI de bencher
.
Para más detalles, consulta la documentación de instalación de la CLI de 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"
⠀
Ahora, verifiquemos que tienes instalada la CLI de bencher
. Ejecuta:
bencher --version
bencher --version
bencher --version
bencher --version
Deberías ver:
bencher 0.5.0
Ejecutar bencher up
Con docker
y la CLI de bencher
instalados, ahora puedes ejecutar los servidores Console y API
con el subcomando de CLI bencher up
.
Ejecuta:
bencher up
bencher up
bencher up
bencher up
Deberías ver algo como:
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...
Una vez más, está bien si tu salida es diferente. Lo importante es que este comando funcione.
🐰 Si obtienes un error de
ghcr.io
que dice:"authentication required"
Intenta ejecutar:docker logout ghcr.io
Seleccione su Marco de Referencia
Si ya tiene puntos de referencia escritos, seleccione su lenguaje de programación y el marco de referencia de la lista a continuación. De lo contrario, solo omita este paso. Para obtener más detalles, consulte la documentación de adaptadores de marco de referencia.
Rastrear tus Benchmarks
¡Ahora estás listo para rastrear los resultados de tus benchmarks!
Para hacerlo, utilizarás el subcomando CLI bencher run
para ejecutar tus benchmarks y recoger los resultados.
Ejecuta:
⠀
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'"
Es posible que necesites modificar el comando de benchmark para que coincida con tu configuración.
Si aún no tienes ningún benchmark, puedes simplemente usar el subcomando bencher mock
como tu comando de benchmark para generar algunos datos simulados.
Si todo funciona como se espera, el final de la salida debería verse algo así:
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
Ahora puedes ver los resultados de cada uno de tus benchmarks en el navegador.
Haz clic o copia y pega los enlaces de Ver resultados
.
Para reclamar el proyecto, haz clic o copia y pega el enlace Reclamar este proyecto
en tu navegador.
🐰 ¡Felicidades! ¡Has seguido tus primeros resultados de evaluación con Bencher Autohospedado! 🎉