Skip to content

Commit 45d9579

Browse files
committed
Add benchmarks, Closes #18
1 parent d246ce0 commit 45d9579

File tree

9 files changed

+707
-19
lines changed

9 files changed

+707
-19
lines changed

at-jmh/build.gradle

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
plugins {
2+
id 'java-library'
3+
id 'net.minecraftforge.licenser'
4+
}
5+
6+
configurations {
7+
jmhOnly
8+
}
9+
10+
repositories {
11+
mavenCentral()
12+
}
13+
14+
java {
15+
toolchain.languageVersion = JavaLanguageVersion.of(8)
16+
withSourcesJar()
17+
}
18+
19+
license {
20+
header = rootProject.file("LICENSE-header.txt")
21+
newLine = false
22+
}
23+
24+
dependencies {
25+
implementation rootProject
26+
implementation libs.jmh.core
27+
implementation libs.asm
28+
29+
jmhOnly sourceSets.main.output
30+
jmhOnly libs.bundles.jmh
31+
32+
annotationProcessor libs.jmh.generator.annprocess
33+
}
34+
35+
tasks.register('jmh', JavaExec) {
36+
dependsOn rootProject.tasks.named('build')
37+
dependsOn sourceSets.main.output
38+
39+
javaLauncher.set(javaToolchains.launcherFor {
40+
languageVersion = JavaLanguageVersion.of(17)
41+
})
42+
jvmArgs = [
43+
'-p', sourceSets.main.runtimeClasspath.asPath,
44+
'--add-modules', 'ALL-MODULE-PATH',
45+
]
46+
classpath = files(configurations.jmhOnly.asPath)
47+
mainClass = 'org.openjdk.jmh.Main'
48+
49+
args '-bm', 'avgt' // benchmark mode
50+
args '-r', '5s' // iteration time
51+
args '-w', '5s' // warmup time
52+
args '-wi', '2' // warmup iterations
53+
54+
// profilers
55+
//args '-prof', 'stack'
56+
args '-prof', "jfr:dir=${project.layout.buildDirectory.asFile.get()}/jfr"
57+
58+
args '-tu', 'us' // time unit
59+
args '-i', '2' // iterations
60+
args '-f', '1' // forks
61+
args '-rff', project.file("${rootProject.layout.buildDirectory.asFile.get()}/jmh_results.txt") // results file
62+
args 'net.minecraftforge.accesstransformer.benchmarks.AccessTransformerListBenchmark'
63+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) Forge Development LLC
3+
* SPDX-License-Identifier: LGPL-2.1-only
4+
*/
5+
package net.minecraftforge.accesstransformer.benchmarks;
6+
7+
import net.minecraftforge.accesstransformer.parser.AccessTransformerList;
8+
import org.openjdk.jmh.annotations.Benchmark;
9+
import org.openjdk.jmh.annotations.Scope;
10+
import org.openjdk.jmh.annotations.Setup;
11+
import org.openjdk.jmh.annotations.State;
12+
import org.openjdk.jmh.infra.Blackhole;
13+
import org.objectweb.asm.Type;
14+
15+
@State(Scope.Benchmark)
16+
public class AccessTransformerListBenchmark {
17+
private AccessTransformerList staticList;
18+
19+
@Setup
20+
public void setup() throws Exception {
21+
staticList = new AccessTransformerList();
22+
staticList.loadFromResource("accesstransformer_forge_119.cfg");
23+
staticList.loadFromResource("accesstransformer_firstaid_119.cfg");
24+
staticList.loadFromResource("accesstransformer_jei_119.cfg");
25+
}
26+
27+
@Benchmark
28+
public void testATLoad(Blackhole blackhole) throws Exception {
29+
AccessTransformerList list = new AccessTransformerList();
30+
list.loadFromResource("accesstransformer_forge_119.cfg");
31+
list.loadFromResource("accesstransformer_firstaid_119.cfg");
32+
list.loadFromResource("accesstransformer_jei_119.cfg");
33+
blackhole.consume(list);
34+
}
35+
36+
@Benchmark
37+
public void testAtContainsMiss(Blackhole blackhole) throws Exception {
38+
if (staticList.containsClassTarget(Type.getObjectType("net/minecraft/client/gui/font/FontManager")))
39+
throw new RuntimeException("Didn't expect to find FontManager!");
40+
}
41+
42+
@Benchmark
43+
public void testAtContainsHit(Blackhole blackhole) throws Exception {
44+
if (!staticList.containsClassTarget(Type.getObjectType("net/minecraft/client/gui/Gui")))
45+
throw new RuntimeException("Expected to find Gui!");
46+
}
47+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public net.minecraft.client.gui.Gui f_92976_ # healthUpdateCounter
2+
3+
public-f net.minecraft.world.entity.Entity f_19804_ # dataManager
4+
5+
public net.minecraft.server.level.ServerLevel f_8550_ # allPlayersSleeping
6+
7+
public net.minecraft.world.entity.LivingEntity m_21262_(Lnet/minecraft/world/damagesource/DamageSource;)Z # checkTotemDeathProtection
8+
public net.minecraft.world.entity.LivingEntity f_20961_ # HEALTH
9+
10+
public net.minecraft.world.entity.player.Player f_36107_ # ABSORPTION
11+
12+
public net.minecraft.network.syncher.SynchedEntityData m_135375_(Lnet/minecraft/network/syncher/SynchedEntityData$DataItem;Lnet/minecraft/network/syncher/SynchedEntityData$DataItem;)V # setEntryValue
13+
public net.minecraft.network.syncher.SynchedEntityData m_135379_(Lnet/minecraft/network/syncher/EntityDataAccessor;)Lnet/minecraft/network/syncher/SynchedEntityData$DataItem; # getEntry
14+
15+
public net.minecraft.world.item.enchantment.EnchantmentHelper m_44850_(Lnet/minecraft/world/item/enchantment/EnchantmentHelper$EnchantmentVisitor;Lnet/minecraft/world/item/ItemStack;)V # runIterationOnItem
16+
public net.minecraft.world.item.enchantment.EnchantmentHelper$EnchantmentVisitor
17+
18+
# For FirstaidIngameGui
19+
public net.minecraft.client.gui.Gui f_92989_ #tickCount
20+
public net.minecraft.client.gui.Gui f_92973_ #lastHealth
21+
public net.minecraft.client.gui.Gui f_92975_ #lastHealthTime
22+
public net.minecraft.client.gui.Gui f_92974_ #displayHealth
23+
public net.minecraft.client.gui.Gui f_92985_ #random

0 commit comments

Comments
 (0)