Skip to content

Instantly share code, notes, and snippets.

@amaembo
Created August 26, 2015 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amaembo/fab1f18eb39939b6eba9 to your computer and use it in GitHub Desktop.
Save amaembo/fab1f18eb39939b6eba9 to your computer and use it in GitHub Desktop.
# JMH 1.10.3 (released 40 days ago)
# VM version: JDK 1.7.0_80, VM 24.80-b11
...
Benchmark Mode Cnt Score Error Units
SplitTest.plain avgt 30 0,107 ± 0,001 us/op
SplitTest.quote avgt 30 0,393 ± 0,003 us/op
# JMH 1.10.3 (released 40 days ago)
# VM version: JDK 1.8.0_40, VM 25.40-b25
...
Benchmark Mode Cnt Score Error Units
SplitTest.plain avgt 30 0,108 ± 0,001 us/op
SplitTest.quote avgt 30 0,380 ± 0,004 us/op
# JMH 1.10.3 (released 40 days ago)
# VM version: JDK 1.9.0-ea, VM 1.9.0-ea-b72
...
Benchmark Mode Cnt Score Error Units
SplitTest.plain avgt 30 0,108 ± 0,001 us/op
SplitTest.quote avgt 30 0,375 ± 0,003 us/op
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.annotations.*;
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Fork(3)
@State(Scope.Benchmark)
public class SplitTest {
String s = "aa?bb";
@Benchmark
public void quote(Blackhole bh) {
bh.consume(s.split(Pattern.quote("?")));
}
@Benchmark
public void plain(Blackhole bh) {
bh.consume(s.split("\\?"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment