Created
February 22, 2023 09:01
-
-
Save l0rinc/d9ea3e6b10015c8207fa3f4e6f867be6 to your computer and use it in GitHub Desktop.
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
@BenchmarkMode(Mode.Throughput) | |
@State(Scope.Benchmark) | |
@Fork(value = 1) | |
@Measurement(iterations = 3, time = 1) | |
@Warmup(iterations = 3, time = 1) | |
public class LongNumberParsing { | |
static final String DIGITS = "1234567890"; | |
static final int REPETITIONS = 100; | |
static final String LONG_INT = join("", nCopies(REPETITIONS, DIGITS)); | |
static final String LONG_FP = DIGITS + "." + join("", nCopies(REPETITIONS - 1, DIGITS)); | |
@Benchmark public double perfParseDouble() { return Double.parseDouble(LONG_FP); } | |
@Benchmark public Object perfParseBigDecimal() { return new BigDecimal(LONG_FP); } | |
@Benchmark public Object perfParseBigInteger() { return new BigInteger(LONG_INT); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment