Created
April 13, 2020 15:23
-
-
Save sadiqj/1e4d299adbad36bf51bbe41859dfb1b5 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 com.opsian; | |
| import org.openjdk.jmh.Main; | |
| import org.openjdk.jmh.annotations.*; | |
| import org.openjdk.jmh.infra.Blackhole; | |
| import org.openjdk.jmh.runner.options.OptionsBuilder; | |
| import org.openjdk.jol.info.ClassLayout; | |
| import com.opsian.*; | |
| import java.util.Random; | |
| import java.util.concurrent.TimeUnit; | |
| @State(Scope.Benchmark) | |
| public class TlabTest { | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:-UseTLAB"}) | |
| @Threads(1) | |
| public Object allocateWithoutTLABOneThreadObj() { | |
| return new Object(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:+UseTLAB"}) | |
| @Threads(1) | |
| public Object allocateWithTLABOneThreadsObj() { | |
| return new Object(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:-UseTLAB"}) | |
| @Threads(4) | |
| public Object allocateWithoutTLABFourThreadsObj() { | |
| return new Object(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:+UseTLAB"}) | |
| @Threads(4) | |
| public Object allocateWithTLABFourThreadsObj() { | |
| return new Object(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:-UseTLAB"}) | |
| @Threads(1) | |
| public Object allocateWithoutTLABOneThreadSmall() { | |
| return new SmallObj(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:+UseTLAB"}) | |
| @Threads(1) | |
| public Object allocateWithTLABOneThreadsSmall() { | |
| return new SmallObj(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:-UseTLAB"}) | |
| @Threads(4) | |
| public Object allocateWithoutTLABFourThreadsSmall() { | |
| return new SmallObj(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:+UseTLAB"}) | |
| @Threads(4) | |
| public Object allocateWithTLABFourThreadsSmall() { | |
| return new SmallObj(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:-UseTLAB"}) | |
| @Threads(1) | |
| public Object allocateWithoutTLABOneThreadLarge() { | |
| return new LargeObj(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:+UseTLAB"}) | |
| @Threads(1) | |
| public Object allocateWithTLABOneThreadsLarge() { | |
| return new LargeObj(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:-UseTLAB"}) | |
| @Threads(4) | |
| public Object allocateWithoutTLABFourThreadsLarge() { | |
| return new LargeObj(); | |
| } | |
| @Benchmark | |
| @Fork(jvmArgsAppend = {"-XX:+UseParallelGC","-XX:+UseTLAB"}) | |
| @Threads(4) | |
| public Object allocateWithTLABFourThreadsLarge() { | |
| return new LargeObj(); | |
| } | |
| public static void main(String[] args) throws Exception { | |
| Main.main(args); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment