Created
August 26, 2015 12:50
-
-
Save amaembo/fab1f18eb39939b6eba9 to your computer and use it in GitHub Desktop.
In reply to http://ru.stackoverflow.com/a/445008/183331
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
# 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 |
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
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