Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
JMH Multiple Benchmarks Different results on isolated runs

I run some benchmarks through JMH

Supposing I have three benchmarks listed in one Java File

    @Benchmark
    @Threads(value = 2)
    @Warmup(iterations = 10)
    @Fork(value = 2)
    @Measurement(iterations = 10)
    public String benchmarkA() {
        ...
    }

    @Benchmark
    @Threads(value = 2)
    @Warmup(iterations = 10)
    @Fork(value = 2)
    @Measurement(iterations = 10)
    public String benchmarkB() {
       ...
    }

    @Benchmark
    @Threads(value = 2)
    @Warmup(iterations = 10)
    @Fork(value = 2)
    @Measurement(iterations = 10)
    public String benchmarkC() {
        ...
    }

Each method benchmarks a different algorithm that serves the same purpose. When I run all the benchmarks together, results vary in comparison to running the benchmarks one by one.

For example execute a JMH run with only onw benchmark on the Java file.

    @Benchmark
    @Threads(value = 2)
    @Warmup(iterations = 10)
    @Fork(value = 2)
    @Measurement(iterations = 10)
    public String benchmarkA() {
        ...
    }

The results for this method would be better If only this method runs, however in the case of more benchmarks the results would be worse.

Supposing result wise benchmarkA > benchmarkB > benchmarkC by running them isolated, if I run them all in one go the differences between them get amplified.

Also I tried changing the order of the benchmarks (executed in lexicographic order) and the results are the same. It is as if the number of benchmarks affects the results.

What could be a reason?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Each benchmark is executed in its own JVM (unless explicitly set to behave otherwise), so cross benchmark pollution should not happen. What can happen, and is quite common, is the thermal throttling of your CPU. If you are benchmarking in an environment where you have no control over CPU frequency the typical behaviour would be for the first benchmark to push CPU frequency up, and later benchmarks to get throttled. You can control for this variable in Linux environments by switching to a user controlled power governor and setting a fixed frequency for your CPU.

over 4 years ago · Santiago Trujillo Relatório

0

Indeed dynamic scaling of CPU frequency can be one of the reasons for this problem.

I found this issue quite helpful for prepping environment for benchmarking.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda