Created
December 17, 2024 13:53
-
-
Save franz1981/d169ff9a7a3dc5c1ff4de45271ab755f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package redhat.app.services.benchmark; | |
import java.util.concurrent.TimeUnit; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.BenchmarkMode; | |
import org.openjdk.jmh.annotations.CompilerControl; | |
import org.openjdk.jmh.annotations.Fork; | |
import org.openjdk.jmh.annotations.Measurement; | |
import org.openjdk.jmh.annotations.Mode; | |
import org.openjdk.jmh.annotations.OutputTimeUnit; | |
import org.openjdk.jmh.annotations.Scope; | |
import org.openjdk.jmh.annotations.State; | |
import org.openjdk.jmh.annotations.Warmup; | |
/** | |
* This benchmark should be used with the following JVM options to tune the tier compilation level: | |
* -XX:TieredStopAtLevel= | |
* | |
*/ | |
@State(Scope.Benchmark) | |
@Fork(2) | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) | |
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) | |
public class MethodDataSharing { | |
@Benchmark | |
public void doFoo() { | |
foo(1000, true); | |
} | |
@CompilerControl(CompilerControl.Mode.DONT_INLINE) | |
private static int foo(int count, boolean countAll) { | |
int total = 0; | |
for (int i = 0; i < count; i++) { | |
if (countAll) { | |
total++; | |
} | |
} | |
return total; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lstopo shows:

while keeping everything on the same socket
and
perf
analysis shows , in the more costly case:which shows several
metadata(method data for {method} {0x00007fb6104783c8}
comments, which refer to the method data object starting at0x7fb6104de900
, which contains few counters in.