### Build and run FastDoubleParser with Java SE 23 on macOS Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Clone the repository, set JAVA_HOME to a Java 23 installation, compile the main and demo modules with preview features, and run the demo with various data files. The commands use --enable-preview and -source 23, and the -XX:CompileCommand=inline,java/lang/String.charAt option. ```shell git clone https://github.com/wrandelshofer/FastDoubleParser.git cd FastDoubleParser export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-23.jdk/Contents/Home javac --enable-preview -source 23 -d out -encoding utf8 --module-source-path fastdoubleparser-dev/src/main/java --module ch.randelshofer.fastdoubleparser javac --enable-preview -source 23 -d out -encoding utf8 -p out --module-source-path fastdoubleparserdemo-dev/src/main/java --module ch.randelshofer.fastdoubleparserdemo java -XX:CompileCommand=inline,java/lang/String.charAt --enable-preview -p out -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown java -XX:CompileCommand=inline,java/lang/String.charAt --enable-preview -p out -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada.txt java -XX:CompileCommand=inline,java/lang/String.charAt --enable-preview -p out -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/mesh.txt java -XX:CompileCommand=inline,java/lang/String.charAt --enable-preview -p out -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada_hex.txt ``` -------------------------------- ### Java usage example for FastDoubleParser Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Shows how to parse doubles, floats, big decimals, big integers, JSON doubles, and configurable locale-specific numbers. The parse methods accept CharacterSequence, char arrays, or byte arrays; parsing from arrays is faster due to SIMD instructions. ```java import ch.randelshofer.fastdoubleparser.JavaDoubleParser; import ch.randelshofer.fastdoubleparser.JavaFloatParser; import ch.randelshofer.fastdoubleparser.JavaBigDecimalParser; import ch.randelshofer.fastdoubleparser.JavaBigIntegerParser; import ch.randelshofer.fastdoubleparser.JsonDoubleParser; import ch.randelshofer.fastdoubleparser.NumberFormatSymbols; import ch.randelshofer.fastdoubleparser.ConfigurableDoubleParser; import java.math.BigDecimal; import java.math.BigInteger; import java.text.DecimalFormatSymbols; import java.util.List; import java.util.Locale; import java.util.Set; class MyMain { public static void main(String... args) { double d = JavaDoubleParser.parseDouble("1.2345e135"); System.out.println("Java double value: " + d); float f = JavaFloatParser.parseFloat("1.2345f"); System.out.println("Java float value: " + f); BigDecimal bd = JavaBigDecimalParser.parseBigDecimal("1.2345"); System.out.println("Java big decimal value: " + bd); BigInteger bi = JavaBigIntegerParser.parseBigInteger("12345"); System.out.println("Java big integer value: " + bi); double jsonD = JsonDoubleParser.parseDouble("1.2345e85"); System.out.println("JSON double value: " + jsonD); var symbols = NumberFormatSymbols.fromDecimalFormatSymbols(new DecimalFormatSymbols(Locale.GERMAN)); boolean ignoreCase = true; var confdParser = new ConfigurableDoubleParser(symbols, ignoreCase); double confD1 = confdParser.parseDouble("123.456,89e5"); double confD2 = confdParser.parseDouble("-0.15425,89E-5"); System.out.println("Double value in German Locale: " + confD1); System.out.println("Another double value in German Locale: " + confD2); symbols = NumberFormatSymbols.fromDecimalFormatSymbols(new DecimalFormatSymbols(Locale.forLanguageTag("zh-CN"))); symbols = symbols .withDigits(List.of('〇', '一', '二', '三', '四', '五', '六', '七', '八', '九')) .withExponentSeparator((Set.of("*一〇^"))); confdParser = new ConfigurableDoubleParser(symbols, ignoreCase); double confZh = confdParser.parseDouble("四一.五七五三七一六六二一四五九八*一〇^七"); System.out.println("Double value in Chinese Locale: " + confZh); } } ``` -------------------------------- ### Clone, build, and run FastDoubleParser benchmark on Java 23 Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Clones the repository, sets JAVA_HOME to Azul Zulu 23, builds with Maven, and runs the demo with and without data files using the module path. ```shell git clone https://github.com/wrandelshofer/FastDoubleParser.git cd FastDoubleParser export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-23.jdk/Contents/Home mvn clean mvn package export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-23.jdk/Contents/Home java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada.txt java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/mesh.txt java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada_hex.txt ``` -------------------------------- ### Create bundle.jar for Nexus deployment Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/deployment/deployment.md Shell commands to copy JAR files, add license and notice files, sign all JARs and POMs with GPG, and create a bundle.jar for upload to the Nexus repository manager. ```shell cp ../fastdoubleparser/target/*.jar . cp ../fastdoubleparser-java23/target/*javadoc.jar fastdoubleparser-2.0.1-javadoc.jar rm -rf META-INF mkdir META-INF cp ../LICENSE META-INF cp ../fastdoubleparser-dev/src/main/resources/ch.randelshofer.fastdoubleparser/META-INF/thirdparty-LICENSE META-INF cp ../NOTICE META-INF jar -uf fastdoubleparser-2.0.1-javadoc.jar META-INF/* jar -uf fastdoubleparser-2.0.1-sources.jar META-INF/* rm *.asc for f in *.jar; do gpg -ab "$f"; done for f in *.xml; do gpg -ab "$f"; done rm *bundle.jar jar -cf fastdoubleparser-2.0.1-bundle.jar $(ls -1 pom*|xargs) $(ls -1 fastdoubleparser*|xargs) ``` -------------------------------- ### Run FastDoubleParser benchmark on Java 17 Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Sets JAVA_HOME to Azul Zulu 17 and runs the demo with and without data files using the module path. ```shell export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada.txt java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/mesh.txt java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada_hex.txt ``` -------------------------------- ### Run FastDoubleParser benchmark on Java 21 Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Sets JAVA_HOME to Azul Zulu 21 and runs the demo with and without data files using the module path. ```shell export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada.txt java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/mesh.txt java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada_hex.txt ``` -------------------------------- ### Run FastDoubleParser benchmark on Java 11 Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Sets JAVA_HOME to Azul Zulu 11 and runs the demo with and without data files using the module path. ```shell export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada.txt java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/mesh.txt java -XX:CompileCommand=inline,java/lang/String.charAt -p fastdoubleparser/target:fastdoubleparserdemo/target -m ch.randelshofer.fastdoubleparserdemo/ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada_hex.txt ``` -------------------------------- ### Run FastDoubleParser demo with JVM inline directive Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Command-line invocation for the FastDoubleParser demo, using -XX:CompileCommand to inline String.charAt for performance. The classpath includes both fastdoubleparser and fastdoubleparserdemo target directories, and the demo processes the canada_hex.txt file with Markdown output. ```bash java -XX:CompileCommand=inline,java/lang/String.charAt -cp "fastdoubleparser/target/*:fastdoubleparserdemo/target/*" ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada_hex.txt ``` -------------------------------- ### Run FastDoubleParser benchmark on Java 8 Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Sets JAVA_HOME to Azul Zulu 8 and runs the demo with and without data files using the classpath with wildcards. ```shell export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-8.jdk/Contents/Home java -XX:CompileCommand=inline,java/lang/String.charAt -cp "fastdoubleparser/target/*:fastdoubleparserdemo/target/*" ch.randelshofer.fastdoubleparserdemo.Main --markdown java -XX:CompileCommand=inline,java/lang/String.charAt -cp "fastdoubleparser/target/*:fastdoubleparserdemo/target/*" ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/canada.txt java -XX:CompileCommand=inline,java/lang/String.charAt -cp "fastdoubleparser/target/*:fastdoubleparserdemo/target/*" ch.randelshofer.fastdoubleparserdemo.Main --markdown FastDoubleParserDemo/data/mesh.txt ``` -------------------------------- ### Benchmark command and output for random numbers Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Command to run the benchmark with default settings (random numbers) and its output, showing throughput and speedup for JavaDoubleParser variants compared to java.lang.Double and C libraries. ```text $ ./build/benchmarks/benchmark # parsing random numbers available models (-m): uniform one_over_rand32 simple_uniform32 simple_int32 int_e_int simple_int64 bigint_int_dot_int big_ints model: generate random numbers uniformly in the interval [0.0.1.0] volume: 100000 floats volume = 2.09808 MB netlib : 317.31 MB/s (+/- 6.0 %) 15.12 Mfloat/s 66.12 ns/f doubleconversion : 263.89 MB/s (+/- 4.2 %) 12.58 Mfloat/s 79.51 ns/f strtod : 86.13 MB/s (+/- 3.7 %) 4.10 Mfloat/s 243.61 ns/f abseil : 467.27 MB/s (+/- 9.0 %) 22.27 Mfloat/s 44.90 ns/f fastfloat : 880.79 MB/s (+/- 6.6 %) 41.98 Mfloat/s 23.82 ns/f Java 22, OpenJDK 64-Bit Server VM, Oracle Corporation, 22.0.1+8-16 java.lang.Double : 94.32 MB/s (+/- 3.1 %) 5.41 Mfloat/s 184.73 ns/f 1.00 speedup JavaDoubleParser CharSequence: 585.84 MB/s (+/-12.4 %) 33.62 Mfloat/s 29.74 ns/f 6.21 speedup JavaDoubleParser char[] : 659.27 MB/s (+/- 9.6 %) 37.84 Mfloat/s 26.43 ns/f 6.99 speedup JavaDoubleParser byte[] : 729.46 MB/s (+/- 9.7 %) 41.86 Mfloat/s 23.89 ns/f 7.73 speedup ``` -------------------------------- ### Benchmark command and output for canada.txt file Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Command to run the benchmark on the canada.txt file and its output, showing throughput and speedup for JavaDoubleParser variants compared to java.lang.Double and C libraries. ```text $ ./build/benchmarks/benchmark -f data/canada.txt # read 111126 lines volume = 1.93374 MB netlib : 337.79 MB/s (+/- 5.8 %) 19.41 Mfloat/s 51.52 ns/f doubleconversion : 254.22 MB/s (+/- 6.0 %) 14.61 Mfloat/s 68.45 ns/f strtod : 73.33 MB/s (+/- 7.1 %) 4.21 Mfloat/s 237.31 ns/f abseil : 411.11 MB/s (+/- 7.3 %) 23.63 Mfloat/s 42.33 ns/f fastfloat : 741.32 MB/s (+/- 5.3 %) 42.60 Mfloat/s 23.47 ns/f Java 22, OpenJDK 64-Bit Server VM, Oracle Corporation, 22.0.1+8-16 java.lang.Double : 87.48 MB/s (+/- 3.2 %) 5.03 Mfloat/s 198.93 ns/f 1.00 speedup JavaDoubleParser CharSequence: 386.93 MB/s (+/- 8.8 %) 22.24 Mfloat/s 44.97 ns/f 4.42 speedup JavaDoubleParser char[] : 637.55 MB/s (+/- 9.0 %) 36.64 Mfloat/s 27.29 ns/f 7.29 speedup JavaDoubleParser byte[] : 694.16 MB/s (+/- 7.9 %) 39.89 Mfloat/s 25.07 ns/f 7.94 speedup ``` -------------------------------- ### Run hand-picked tests with Maven Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Runs a set of hand-picked tests that aim for 100% line coverage using the Maven command with the enableLongRunningTests flag. ```bash mvn -DenableLongRunningTests=true test ``` -------------------------------- ### JVM option to inline String.charAt Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Use this JVM command line option to ensure optimal performance for parse...() methods that take a CharacterSequence argument, as the JVM does not reliably inline String.charAt(int). ```bash -XX:CompileCommand=inline,java/lang/String.charAt ``` -------------------------------- ### Maven dependency for FastDoubleParser Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Add this dependency to your Maven pom.xml to use the FastDoubleParser library. Replace the version placeholder with the actual version. ```xml ch.randelshofer fastdoubleparser …version… ``` -------------------------------- ### Module descriptor for FastDoubleParser Source: https://github.com/wrandelshofer/fastdoubleparser/blob/main/README.md Declare the required module in your module-info.java to use the FastDoubleParser library in a modular Java project. ```java module MyModule { requires ch.randelshofer.fastdoubleparser; } ```