Last active
July 13, 2020 09:32
-
-
Save Janmm14/a5b0babe2da14468907b090dbd7ad288 to your computer and use it in GitHub Desktop.
BungeeCord-Chat translateHexColorCodes JMH Benchmark source
This file contains 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 de.janmm14; | |
import net.md_5.bungee.api.ChatColor; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.BenchmarkMode; | |
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.Threads; | |
import org.openjdk.jmh.annotations.Warmup; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.util.concurrent.TimeUnit; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_matcher; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_matcher_replaceAll; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_replaceAll; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher_chatcolor_of; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher_replaceAll; | |
@Threads(3) | |
@Fork(warmups = 0, value = 1) | |
@Warmup(iterations = 3, time = 4) | |
@Measurement(iterations = 5, time = 5) | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
public class AANoReplacementBench { | |
@Benchmark | |
public void a_shortRegex_matcher_chatcolor_of(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher_chatcolor_of("&#", "", "hello hi hey"))); | |
} | |
@Benchmark | |
public void b_shortRegex_matcher(Blackhole b) throws Throwable { | |
b.consume(translateHexColorCodes_shortRegex_matcher("&#", "", "hello hi hey")); | |
} | |
@Benchmark | |
public void c_shortRegex_matcher_translate(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher("&#", "", "hello hi hey"))); | |
} | |
@Benchmark | |
public void d_longRegex_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_replaceAll("&#", "", "hello hi hey"))); | |
} | |
@Benchmark | |
public void e_longRegex_matcher(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_matcher("&#", "", "hello hi hey"))); | |
} | |
@Benchmark | |
public void f_longRegex_matcher_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_matcher_replaceAll("&#", "", "hello hi hey"))); | |
} | |
@Benchmark | |
public void g_shortRegex_matcher_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher_replaceAll("&#", "", "hello hi hey"))); | |
} | |
@Benchmark | |
public void h_colorize(Blackhole b) throws Throwable { | |
b.consume(BungeeChatExtension.colorize("hello hi hey")); | |
} | |
} |
This file contains 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 de.janmm14; | |
import net.md_5.bungee.api.ChatColor; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.BenchmarkMode; | |
import org.openjdk.jmh.annotations.Fork; | |
import org.openjdk.jmh.annotations.GroupThreads; | |
import org.openjdk.jmh.annotations.Measurement; | |
import org.openjdk.jmh.annotations.Mode; | |
import org.openjdk.jmh.annotations.OutputTimeUnit; | |
import org.openjdk.jmh.annotations.Threads; | |
import org.openjdk.jmh.annotations.Warmup; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.util.concurrent.TimeUnit; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_matcher; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_matcher_replaceAll; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_replaceAll; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher_chatcolor_of; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher_replaceAll; | |
@Threads(3) | |
@Fork(warmups = 0, value = 1) | |
@Warmup(iterations = 3, time = 4) | |
@Measurement(iterations = 5, time = 5) | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
public class AShortBench { | |
@Benchmark | |
public void a_shortRegex_matcher_chatcolor_of(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher_chatcolor_of("&#", "", "b3d5fWelcome to Dingdong"))); | |
} | |
@Benchmark | |
public void b_shortRegex_matcher(Blackhole b) throws Throwable { | |
b.consume(translateHexColorCodes_shortRegex_matcher("&#", "", "b3d5fWelcome to Dingdong")); | |
} | |
@Benchmark | |
public void c_shortRegex_matcher_translate(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher("&#", "", "b3d5fWelcome to Dingdong"))); | |
} | |
@Benchmark | |
public void d_longRegex_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_replaceAll("&#", "", "b3d5fWelcome to Dingdong"))); | |
} | |
@Benchmark | |
public void e_longRegex_matcher(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_matcher("&#", "", "b3d5fWelcome to Dingdong"))); | |
} | |
@Benchmark | |
public void f_longRegex_matcher_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_matcher_replaceAll("&#", "", "b3d5fWelcome to Dingdong"))); | |
} | |
@Benchmark | |
public void g_shortRegex_matcher_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher_replaceAll("&#", "", "b3d5fWelcome to Dingdong"))); | |
} | |
@Benchmark | |
public void h_colorize(Blackhole b) throws Throwable { | |
b.consume(BungeeChatExtension.colorize("b3d5fWelcome to Dingdong")); | |
} | |
} |
This file contains 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 de.janmm14; | |
import com.google.common.base.Strings; | |
import com.google.common.cache.Cache; | |
import com.google.common.cache.CacheBuilder; | |
import com.google.common.collect.ImmutableSet; | |
import net.md_5.bungee.api.ChatColor; | |
import java.util.Set; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import static net.md_5.bungee.api.ChatColor.COLOR_CHAR; | |
public class BungeeChatExtension { | |
private static final Cache<String, Pattern> a = CacheBuilder.newBuilder().softValues().build(); | |
private static final Cache<String, Pattern> b = CacheBuilder.newBuilder().softValues().build(); | |
private static final Cache<String, Pattern> c = CacheBuilder.newBuilder().softValues().build(); | |
private static final Cache<String, Pattern> d = CacheBuilder.newBuilder().softValues().build(); | |
private static final Cache<String, Pattern> e = CacheBuilder.newBuilder().softValues().build(); | |
public static String translateHexColorCodes_shortRegex_matcher_chatcolor_of(String startTag, String endTag, String message) throws Throwable { | |
String start = Pattern.quote(startTag); | |
String end = Pattern.quote(endTag); | |
Matcher matcher = a.get(start + '(' + end, | |
() -> Pattern.compile(start + "([0-9a-f]{6})" + end)).matcher(message); | |
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8); //compensates for 4 hex color codes in the message | |
while (matcher.find()) | |
matcher.appendReplacement(buffer, ChatColor.of('#' + matcher.group(1)).toString()); | |
return matcher.appendTail(buffer).toString(); | |
} | |
public static String translateHexColorCodes_shortRegex_matcher(String startTag, String endTag, String message) throws Throwable { | |
String start = Pattern.quote(startTag); | |
String end = Pattern.quote(endTag); | |
Matcher matcher = b.get(start + '(' + end, | |
() -> Pattern.compile(start + "([0-9a-f]{6})" + end)).matcher(message); | |
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8); //compensates for 4 hex color codes in the message | |
while (matcher.find()) { | |
String group = matcher.group(1); | |
matcher.appendReplacement(buffer, COLOR_CHAR + "x" + COLOR_CHAR + group.charAt(0) | |
+ COLOR_CHAR + group.charAt(1) + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3) | |
+ COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)); | |
} | |
return matcher.appendTail(buffer).toString(); | |
} | |
public static String translateHexColorCodes_longRegex_replaceAll(String startTag, String endTag, String message) { | |
return message.replaceAll(Pattern.quote(startTag) + "([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])" + Pattern.quote(endTag), | |
COLOR_CHAR + "x" + COLOR_CHAR + "$1" + COLOR_CHAR + "$2" + COLOR_CHAR + "$3" | |
+ COLOR_CHAR + "$4" + COLOR_CHAR + "$5" + COLOR_CHAR + "$6"); | |
} | |
public static String translateHexColorCodes_longRegex_matcher(String startTag, String endTag, String message) throws Throwable { | |
String start = Pattern.quote(startTag); | |
String end = Pattern.quote(endTag); | |
Matcher matcher = c.get(start + '(' + end, | |
() -> Pattern.compile(start + "([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])" + end)).matcher(message); | |
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8); //compensates for 4 hex color codes in the message | |
while (matcher.find()) { | |
String group = matcher.group(1); | |
matcher.appendReplacement(buffer, COLOR_CHAR + "x" + COLOR_CHAR + group.charAt(0) | |
+ COLOR_CHAR + group.charAt(1) + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3) | |
+ COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)); | |
} | |
return matcher.appendTail(buffer).toString(); | |
} | |
public static String translateHexColorCodes_longRegex_matcher_replaceAll(String startTag, String endTag, String message) throws Throwable { | |
String start = Pattern.quote(startTag); | |
String end = Pattern.quote(endTag); | |
Matcher matcher = d.get(start + '(' + end, | |
() -> Pattern.compile(start + "([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])" + end)).matcher(message); | |
return matcher.replaceAll(COLOR_CHAR + "x" + COLOR_CHAR + "$1" + COLOR_CHAR + "$2" + COLOR_CHAR + "$3" + COLOR_CHAR + "$4" + COLOR_CHAR + "$5" + COLOR_CHAR + "$6"); | |
} | |
public static String translateHexColorCodes_shortRegex_matcher_replaceAll(String startTag, String endTag, String message) throws Throwable { | |
String start = Pattern.quote(startTag); | |
String end = Pattern.quote(endTag); | |
Matcher matcher = e.get(start + '(' + end, | |
() -> Pattern.compile(start + "([0-9a-f]{6})" + end)).matcher(message); | |
return matcher.replaceAll(matchResult -> { | |
String group = matchResult.group(); | |
return COLOR_CHAR + "x" + COLOR_CHAR + group.charAt(0) | |
+ COLOR_CHAR + group.charAt(1) + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3) | |
+ COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5); | |
}); | |
} | |
// No one really uses the capital ones. | |
private static final Set<Character> COLOR_CODES = ImmutableSet.of('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', | |
'a', 'b', 'c', 'd', 'e', 'f', 'k', 'l', 'm', 'o', 'r'); | |
private static final boolean SIXTEEN = true; // Check if a sound name or something exists in 1.16 that doesn't in 1.15 | |
public static String colorize(String str) { | |
if (Strings.isNullOrEmpty(str)) return str; | |
char[] chars = str.toCharArray(); | |
int len = chars.length - 1; | |
if (SIXTEEN) { | |
StringBuilder builder = new StringBuilder(len + 4 * 8); | |
int hexState = -1; | |
for (int i = 0; i < len; i++) { | |
// We reached '#' (x) in our string. Just skip it and go for the hex number. | |
if (hexState == 0) { | |
hexState = 1; | |
continue; | |
} | |
char current = chars[i]; | |
if (hexState > 0) { | |
if (Character.isDigit(current)) { | |
builder.append(ChatColor.COLOR_CHAR).append(current); | |
if (hexState++ == 6) hexState = -1; | |
} else { | |
// If it's not a full 6 digits on the way we'll just continue adding it normally and | |
// ignore the translated ones as it's the user's fault. | |
hexState = -1; | |
builder.append(current); | |
} | |
} else { | |
if (current == '&') { | |
char next = chars[i + 1]; | |
if (next == '#' || COLOR_CODES.contains(next)) { | |
builder.append(ChatColor.COLOR_CHAR); | |
if (next == '#') { | |
builder.append('x'); | |
hexState = 0; | |
} | |
} else builder.append('&'); | |
} else builder.append(current); | |
} | |
} | |
if (hexState == 6) builder.append(ChatColor.COLOR_CHAR); | |
builder.append(chars[len]); | |
return builder.toString(); | |
} else { | |
for (int i = 0; i < len; i++) { | |
if (chars[i] == '&' && COLOR_CODES.contains(chars[i + 1])) chars[i] = ChatColor.COLOR_CHAR; | |
} | |
return new String(chars); | |
} | |
} | |
} |
This file contains 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 de.janmm14; | |
import java.util.concurrent.TimeUnit; | |
public class JMHBenchMain { | |
public static void main(String[] args) throws Throwable { | |
System.out.println("Waiting 10 seconds before starting..."); | |
Thread.sleep(TimeUnit.SECONDS.toMillis(9)); | |
System.out.println("Starting in 1 second..."); | |
Thread.sleep(TimeUnit.SECONDS.toMillis(1)); | |
System.out.println("Starting now..."); | |
org.openjdk.jmh.Main.main(args); | |
} | |
} |
This file contains 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 de.janmm14; | |
import net.md_5.bungee.api.ChatColor; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.BenchmarkMode; | |
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.Threads; | |
import org.openjdk.jmh.annotations.Warmup; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.util.concurrent.TimeUnit; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_matcher; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_matcher_replaceAll; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_replaceAll; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher_chatcolor_of; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher_replaceAll; | |
@Threads(3) | |
@Fork(warmups = 0, value = 1) | |
@Warmup(iterations = 3, time = 4) | |
@Measurement(iterations = 5, time = 5) | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
public class LongBench { | |
@Benchmark | |
public void shortRegex_matcher_chatcolor_of(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher_chatcolor_of("&#", "", "Hi, this is a longer b3d5f Test, so it is more&#f5d3b1 complicated."))); | |
} | |
@Benchmark | |
public void shortRegex_matcher(Blackhole b) throws Throwable { | |
b.consume(translateHexColorCodes_shortRegex_matcher("&#", "", "Hi, this is a longer b3d5f Test, so it is more&#f5d3b1 complicated.")); | |
} | |
@Benchmark | |
public void shortRegex_matcher_translate(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher("&#", "", "Hi, this is a longer b3d5f Test, so it is more&#f5d3b1 complicated."))); | |
} | |
@Benchmark | |
public void longRegex_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_replaceAll("&#", "", "Hi, this is a longer b3d5f Test, so it is more&#f5d3b1 complicated."))); | |
} | |
@Benchmark | |
public void longRegex_matcher(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_matcher("&#", "", "Hi, this is a longer b3d5f Test, so it is more&#f5d3b1 complicated."))); | |
} | |
@Benchmark | |
public void longRegex_matcher_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_matcher_replaceAll("&#", "", "Hi, this is a longer b3d5f Test, so it is more&#f5d3b1 complicated."))); | |
} | |
@Benchmark | |
public void shortRegex_matcher_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher_replaceAll("&#", "", "Hi, this is a longer b3d5f Test, so it is more&#f5d3b1 complicated."))); | |
} | |
@Benchmark | |
public void colorize(Blackhole b) throws Throwable { | |
b.consume(BungeeChatExtension.colorize("Hi, this is a longer b3d5f Test, so it is more&#f5d3b1 complicated.")); | |
} | |
} |
This file contains 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 de.janmm14; | |
import net.md_5.bungee.api.ChatColor; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.BenchmarkMode; | |
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.Threads; | |
import org.openjdk.jmh.annotations.Warmup; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.util.concurrent.TimeUnit; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_matcher; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_matcher_replaceAll; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_longRegex_replaceAll; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher_chatcolor_of; | |
import static de.janmm14.BungeeChatExtension.translateHexColorCodes_shortRegex_matcher_replaceAll; | |
@Threads(3) | |
@Fork(warmups = 0, value = 1) | |
@Warmup(iterations = 3, time = 4) | |
@Measurement(iterations = 5, time = 5) | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
public class MostComplicatedBench { | |
@Benchmark | |
public void a_shortRegex_matcher_chatcolor_of(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher_chatcolor_of("&#", "", "hello hi 񮭛 and &2of course a &c&l&mlittle bit of 񢞧𹏙 and &l&2&4&l a little bit of 񩴻 and 񧚏 maybe 񩳃"))); | |
} | |
@Benchmark | |
public void b_shortRegex_matcher(Blackhole b) throws Throwable { | |
b.consume(translateHexColorCodes_shortRegex_matcher("&#", "", "hello hi 񮭛 and &2of course a &c&l&mlittle bit of 񢞧𹏙 and &l&2&4&l a little bit of 񩴻 and 񧚏 maybe 񩳃")); | |
} | |
@Benchmark | |
public void c_shortRegex_matcher_translate(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher("&#", "", "hello hi 񮭛 and &2of course a &c&l&mlittle bit of 񢞧𹏙 and &l&2&4&l a little bit of 񩴻 and 񧚏 maybe 񩳃"))); | |
} | |
@Benchmark | |
public void d_longRegex_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_replaceAll("&#", "", "hello hi 񮭛 and &2of course a &c&l&mlittle bit of 񢞧𹏙 and &l&2&4&l a little bit of 񩴻 and 񧚏 maybe 񩳃"))); | |
} | |
@Benchmark | |
public void e_longRegex_matcher(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_matcher("&#", "", "hello hi 񮭛 and &2of course a &c&l&mlittle bit of 񢞧𹏙 and &l&2&4&l a little bit of 񩴻 and 񧚏 maybe 񩳃"))); | |
} | |
@Benchmark | |
public void f_longRegex_matcher_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_longRegex_matcher_replaceAll("&#", "", "hello hi 񮭛 and &2of course a &c&l&mlittle bit of 񢞧𹏙 and &l&2&4&l a little bit of 񩴻 and 񧚏 maybe 񩳃"))); | |
} | |
@Benchmark | |
public void g_shortRegex_matcher_replaceAll(Blackhole b) throws Throwable { | |
b.consume(ChatColor.translateAlternateColorCodes('&', translateHexColorCodes_shortRegex_matcher_replaceAll("&#", "", "hello hi 񮭛 and &2of course a &c&l&mlittle bit of 񢞧𹏙 and &l&2&4&l a little bit of 񩴻 and 񧚏 maybe 񩳃"))); | |
} | |
@Benchmark | |
public void h_colorize(Blackhole b) throws Throwable { | |
b.consume(BungeeChatExtension.colorize("hello hi 񮭛 and &2of course a &c&l&mlittle bit of 񢞧𹏙 and &l&2&4&l a little bit of 񩴻 and 񧚏 maybe 񩳃")); | |
} | |
} |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.example</groupId> | |
<artifactId>bungeecord-chat-jmh</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<properties> | |
<maven.compiler.source>1.14</maven.compiler.source> | |
<maven.compiler.target>1.14</maven.compiler.target> | |
</properties> | |
<repositories> | |
<repository> | |
<id>bungeecord-repo</id> | |
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | |
</repository> | |
</repositories> | |
<dependencies> | |
<dependency> | |
<groupId>org.openjdk.jmh</groupId> | |
<artifactId>jmh-core</artifactId> | |
<version>1.23</version> | |
</dependency> | |
<dependency> | |
<groupId>org.openjdk.jmh</groupId> | |
<artifactId>jmh-generator-annprocess</artifactId> | |
<version>1.23</version> | |
</dependency> | |
<dependency> | |
<groupId>net.md-5</groupId> | |
<artifactId>bungeecord-chat</artifactId> | |
<version>1.16-R0.2-SNAPSHOT</version> | |
</dependency> | |
<dependency> | |
<groupId>com.google.guava</groupId> | |
<artifactId>guava</artifactId> | |
<version>21.0</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.8.1</version> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment