Bencher Autogerido com Docker Início Rápido
O que é o Bencher?
Bencher é um conjunto de ferramentas de benchmarking contínuas. Já teve algum impacto de regressão de desempenho nos seus usuários? Bencher poderia ter prevenido isso. Bencher permite que você detecte e previna regressões de desempenho antes que cheguem à produção.
- Execute: Execute seus benchmarks localmente ou no CI usando suas ferramentas de benchmarking favoritas. O CLI
bencher
simplesmente envolve seu harness de benchmark existente e armazena seus resultados. - Rastreie: Acompanhe os resultados de seus benchmarks ao longo do tempo. Monitore, consulte e faça gráficos dos resultados usando o console web do Bencher baseado na branch de origem, testbed e medida.
- Capture: Capture regressões de desempenho no CI. Bencher usa análises personalizáveis e de última geração para detectar regressões de desempenho antes que elas cheguem à produção.
Pelos mesmos motivos que os testes de unidade são executados no CI para prevenir regressões de funcionalidades, benchmarks deveriam ser executados no CI com o Bencher para prevenir regressões de desempenho. Bugs de desempenho são bugs!
Bencher Self-Hosted
O Bencher é de código aberto e pode ser hospedado por você mesmo. Se você estiver interessado em usar o Bencher Cloud, confira o tutorial de início rápido do Bencher Cloud. Este tutorial irá te orientar na configuração do Bencher Self-Hosted com Docker.
🐰 Quando se sentir confortável usando o Bencher Self-Hosted, considere verificar os seguintes recursos:
Instalar o Docker
Para executar os servidores Console e API neste tutorial, você precisará ter o docker
instalado.
Verifique se você tem o docker
instalado. Execute:
docker --version
docker --version
docker --version
docker --version
Você deve ver algo como:
Docker version 20.10.17, build 100c701
Não tem problema se o número da sua versão for diferente. O importante é que este comando funcione.
Caso contrário, siga as instruções para instalar o docker
.
Instalar o bencher
CLI
Selecione seu sistema operacional e execute o comando fornecido para instalar o bencher
CLI.
Para mais detalhes, veja a documentação de instalação do 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"
⠀
Agora, vamos verificar se você tem o bencher
CLI instalado. Execute:
bencher --version
bencher --version
bencher --version
bencher --version
Você deverá ver:
bencher 0.5.0
Executar bencher up
Com docker
e a CLI do bencher
instalados, você pode agora executar os servidores Console e API
com o subcomando CLI bencher up
.
Execute:
bencher up
bencher up
bencher up
bencher up
Você deverá 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...
Novamente, não tem problema se sua saída for diferente. É importante apenas que este comando funcione.
🐰 Se você receber um erro de
ghcr.io
dizendo:"authentication required"
Tente executar:docker logout ghcr.io
Selecione seu Benchmark Harness
Se você já tem benchmarks escritos, selecione sua linguagem de programação e o benchmark harness da lista abaixo. Caso contrário, simplesmente pule esta etapa. Para mais detalhes, veja a documentação dos adaptadores de benchmark harness.
Acompanhe suas Benchmarks
Agora você está pronto para acompanhar os resultados dos seus benchmarks!
Para fazer isso, você usará o subcomando de CLI bencher run
para executar seus benchmarks e coletar os resultados.
Execute:
⠀
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'"
Você pode precisar modificar o comando de benchmark para adequá-lo à sua configuração.
Se você ainda não tem benchmarks, pode usar o subcomando bencher mock
como seu comando de benchmark para gerar alguns dados simulados.
Se tudo funcionar como esperado, o final da saída deve se parecer com isto:
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
Agora você pode visualizar os resultados de cada um dos seus benchmarks no navegador.
Clique ou copie e cole os links de Visualizar resultados
.
Para reivindicar o projeto, clique ou copie e cole o link Reivindicar este projeto
no seu navegador.
🐰 Parabéns! Você rastreou seus primeiros resultados de benchmarks com o Bencher Autogerido! 🎉