Last active
August 29, 2015 14:02
-
-
Save jkeys089/8719d9dbe94dacce04cd to your computer and use it in GitHub Desktop.
Performance of Splitting a Proxy Protocol v1 Header: Pre-compiled Pattern vs Netty StringUtil
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 com.t12y.benchmarks; | |
import io.netty.util.internal.StringUtil; | |
import java.util.regex.Pattern; | |
import org.openjdk.jmh.annotations.GenerateMicroBenchmark; | |
public class PreCompiledRegexVsNettyStringUtil { | |
private static final Pattern SINGLE_SPACE_PATTERN = Pattern.compile(" "); | |
private static final String PROXY_PROTOCOL_STRING = "PROXY TCP4 192.168.0.1 192.168.0.11 56324 443"; | |
@GenerateMicroBenchmark | |
public String[] preCompiledRegex() { | |
return SINGLE_SPACE_PATTERN.split(PROXY_PROTOCOL_STRING); | |
} | |
@GenerateMicroBenchmark | |
public String[] nettyStringUtil() { | |
return StringUtil.split(PROXY_PROTOCOL_STRING, ' '); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment