Questions tagged [jmh]

The Java Microbenchmark Harness (JMH) is a Java harness for building, running, and analysing nano/micro/macro benchmarks written in Java and other languages targetting the JVM.

jmh is a Java harness for building, running, and analysing nano/micro/macro benchmarks written in Java and other languages targetting the JVM. It is part of openjdk.

419 questions
30
votes
2 answers

Consuming stack traces noticeably slower in Java 11 than Java 8

I was comparing the performance of JDK 8 and 11 using jmh 1.21 when I ran across some surprising numbers: Java version: 1.8.0_192, vendor: Oracle Corporation Benchmark Mode Cnt Score Error …
Gili
  • 86,244
  • 97
  • 390
  • 689
30
votes
1 answer

What does OpenJDK JMH "score error" exactly mean?

I am using http://openjdk.java.net/projects/code-tools/jmh/ for benchmarking and i get a result like: Benchmark Mode Samples Score Score error Units o.a.f.c.j.b.TestClass.test1 avgt 5 2372870,600 …
salyh
  • 2,095
  • 1
  • 17
  • 31
29
votes
5 answers

How to use JMH with gradle?

I want to use JMH, an OpenJDK microbenchmark tool, with gradle. However, Im getting the NPE on compilation. On the other hand, JMH works when using from maven. I am not posting any build.gradle as it is basic - apply java plugin and add dependency…
igr
  • 10,199
  • 13
  • 65
  • 111
23
votes
1 answer

Why is JMH saying that returning 1 is faster than returning 0

Can someone explain why JMH saying that returning 1 is faster than returning 0 ? Here is the benchmark code. import org.openjdk.jmh.annotations.*; import…
Artur Mkrtchyan
  • 921
  • 9
  • 9
21
votes
2 answers

Why is logarithm slower in Rust than in Java?

If I run these benchmarks in Rust: #[bench] fn bench_rnd(b: &mut Bencher) { let mut rng = rand::weak_rng(); b.iter(|| rng.gen_range::(2.0, 100.0)); } #[bench] fn bench_ln(b: &mut Bencher) { let mut rng = rand::weak_rng(); …
21
votes
3 answers

shade for parameter resource: Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer

I'm working on a maven project. I'm trying to integrate jmh benchmarking into my project. The pom.xml of my maven project... platform platform-root 3.0-SNAPSHOT
neelrotno
  • 353
  • 1
  • 4
  • 14
18
votes
1 answer

Strange JIT pessimization of a loop idiom

While analyzing the results of a recent question here, I encountered a quite peculiar phenomenon: apparently an extra layer of HotSpot's JIT-optimization actually slows down execution on my machine. Here is the code I have used for the…
Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
17
votes
1 answer

Would Stream.toList() perform better than Collectors.toList()

JDK is introducing an API Stream.toList() with JDK-8180352. Here is a benchmarking code that I have attempted to compare its performance with the existing Collectors.toList: @BenchmarkMode(Mode.All) @Fork(1) @State(Scope.Thread) @Warmup(iterations =…
Naman
  • 27,789
  • 26
  • 218
  • 353
16
votes
2 answers

Benchmarking spring boot application with JMH

I have a spring boot application which I want to benchmark using JMH. Any reference for this integration will be useful.
Soumyajit Swain
  • 1,298
  • 1
  • 21
  • 35
16
votes
1 answer

Understanding JMH Output

So I ran a JMH Benchmark over a few methods and got response like this: I am not able to understand what exactly the Score and Error values signify. Is there some reference documentation available for the same?
AgentX
  • 1,402
  • 3
  • 23
  • 38
16
votes
1 answer

Why does JMH run different forks?

I am using the JMH benchmarking framework (http://openjdk.java.net/projects/code-tools/jmh/) to run benchmarks on my code. My understanding is that JMH forks the JVM multiple times during benchmarking in order to discard any profiles built up by the…
Danny
  • 557
  • 5
  • 16
14
votes
1 answer

Why does performance of java stream fall off with relatively large work compared to "for" loop?

I had an earlier question about interpreting JMH output, which was mostly answered, but I updated the question with another related question, but it would be better to have this be a separate question. This is the original question: Verify JMH…
David M. Karr
  • 14,317
  • 20
  • 94
  • 199
14
votes
1 answer

what is the difference between warmup attribute in Fork and Warmup annotation in jmh?

I'm learning JMH benchmarking using this tutorial. I noticed that there are 2 warmup related stuff for function benchMurmur3_128 in here. so, I have question regarding the difference between warmup attribute in Fork annotation and Warmup annotation…
user51
  • 8,843
  • 21
  • 79
  • 158
14
votes
4 answers

CAS vs synchronized performance

I've had this question for quite a while now, trying to read lots of resources and understanding what is going on - but I've still failed to get a good understanding of why things are the way they are. Simply put I'm trying to test how a CAS would…
Eugene
  • 117,005
  • 15
  • 201
  • 306
14
votes
1 answer

Direct ByteBuffer relative vs absolute read performance

While I was testing the read performance of a direct java.nio.ByteBuffer I noticed that the absolute read is on average 2x times faster than the relative read. Also if I compare the source code of the relative vs absolute read, the code is pretty…
Vladimir G.
  • 418
  • 3
  • 10
1
2
3
27 28