├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── Enough java.lang.String to Hang Ourselves ....pdf ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── int2str.sh ├── results ├── Dmitry_quiz_results.txt ├── Heinz_StringIntrinsics_all_results.txt ├── Heinz_StringIntrinsics_all_results2.txt ├── MacBookPro1-4-2 │ ├── jdk8output │ ├── jdk9output │ └── jdk9outputG1 ├── UbuntuServer2-4-1 │ ├── jdk8output │ ├── jdk9output │ └── jdk9outputG1 ├── all.csv ├── int2str1.txt ├── int2str2.txt ├── int2str3.txt ├── int2str4.txt ├── int2str5.txt ├── int2str6.txt └── playground-server-1-6-2 │ ├── allocation │ ├── java-jdk11-gc-2021-10-21-53-03.out │ ├── java-jdk17-gc-2021-10-21-53-03.out │ ├── java-jdk6-gc-2021-10-21-53-03.out │ ├── java-jdk7-gc-2021-10-21-53-03.out │ └── java-jdk8-gc-2021-10-21-53-03.out │ ├── format-optimized │ ├── java-jdk10-2021-10-21-22-41.out │ ├── java-jdk12-2021-10-21-22-41.out │ ├── java-jdk13-2021-10-21-22-41.out │ ├── java-jdk14-2021-10-21-22-41.out │ ├── java-jdk15-2021-10-21-22-41.out │ ├── java-jdk16-2021-10-21-22-41.out │ ├── java-jdk18-2021-10-21-22-41.out │ └── java-jdk9-2021-10-21-22-41.out │ ├── java-jdk11-2021-10-19-27-02.out │ ├── java-jdk17-2021-10-19-27-02.out │ ├── java-jdk17-nocompact2021-10-22-11-46.out │ ├── java-jdk6-2021-10-19-27-02.out │ ├── java-jdk7-2021-10-19-27-02.out │ ├── java-jdk8-2021-10-19-27-02.out │ ├── plus-algorithms │ ├── java-jdk11-BC_SB-2021-10-22-57-25.out │ ├── java-jdk11-BC_SB_SIZED-2021-10-22-57-25.out │ ├── java-jdk11-BC_SB_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk11-MH_INLINE_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk11-MH_SB_SIZED-2021-10-22-57-25.out │ ├── java-jdk11-MH_SB_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk11-gc-BC_SB-2021-10-22-57-25.out │ ├── java-jdk11-gc-BC_SB_SIZED-2021-10-22-57-25.out │ ├── java-jdk11-gc-BC_SB_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk11-gc-MH_INLINE_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk11-gc-MH_SB_SIZED-2021-10-22-57-25.out │ ├── java-jdk11-gc-MH_SB_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk17-BC_SB-2021-10-22-57-25.out │ ├── java-jdk17-BC_SB_SIZED-2021-10-22-57-25.out │ ├── java-jdk17-BC_SB_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk17-MH_INLINE_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk17-MH_SB_SIZED-2021-10-22-57-25.out │ ├── java-jdk17-MH_SB_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk17-gc-BC_SB-2021-10-22-57-25.out │ ├── java-jdk17-gc-BC_SB_SIZED-2021-10-22-57-25.out │ ├── java-jdk17-gc-BC_SB_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk17-gc-MH_INLINE_SIZED_EXACT-2021-10-22-57-25.out │ ├── java-jdk17-gc-MH_SB_SIZED-2021-10-22-57-25.out │ └── java-jdk17-gc-MH_SB_SIZED_EXACT-2021-10-22-57-25.out │ └── tiered │ ├── java-jdk10-+TieredCompilation-2021-10-22-15-54.out │ ├── java-jdk11-+TieredCompilation-2021-10-22-15-54.out │ ├── java-jdk12-+TieredCompilation-2021-10-22-15-54.out │ ├── java-jdk13-+TieredCompilation-2021-10-22-15-54.out │ ├── java-jdk17-+TieredCompilation-2021-10-22-15-54.out │ ├── java-jdk18-+TieredCompilation-2021-10-22-15-54.out │ ├── java-jdk6-+TieredCompilation-2021-10-22-15-54.out │ ├── java-jdk7-+TieredCompilation-2021-10-22-15-54.out │ ├── java-jdk8-+TieredCompilation-2021-10-22-15-54.out │ └── java-jdk9-+TieredCompilation-2021-10-22-15-54.out ├── runall.sh ├── runconcat.sh ├── rungc.sh ├── runmissing.sh ├── settings.gradle └── src └── main └── java └── eu └── javaspecialists ├── perf ├── string │ ├── AbstractStringAppendBenchmark.java │ ├── HashCodeBenchmark.java │ ├── InternBenchmark.java │ ├── NumberToStringBenchmark.java │ ├── PlainStringAppendBenchmark.java │ ├── StringAppenderAppendBenchmark.java │ ├── StringAppenderBenchmark.java │ ├── StringAppenderConstants.java │ └── StringIntrinsicsBenchmark.java └── util │ ├── ByteWatcherSingleThread.java │ └── Memory.java └── playground ├── BreakCompiler.java ├── BytesCountAppending.java ├── DeduplicationDemo.java ├── IntToStringLazy.java ├── IntToStringStudious.java ├── Key.java ├── KeyDemo.java ├── LargestString.java ├── NumberToStringByteCount.java ├── PXMLTag.java ├── StringAppender.java ├── StringAppenderByteCount.java ├── StringLayout.java └── hasher ├── BruteForceBase.java ├── BruteForceNestedLoops.java ├── BruteForceParallel.java ├── BruteForceRecursive.java ├── BruteForceRecursive2.java ├── HashCodeZero.java └── StringDOS.java /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | continuation_indent_size = 8 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # These files will always have CRLF line endings on checkout 2 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '45 4 * * 0' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'java' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://git.io/codeql-language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v2 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v1 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 52 | 53 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 54 | # If this step fails, then you should remove it and run the build manually (see below) 55 | - name: Autobuild 56 | uses: github/codeql-action/autobuild@v1 57 | 58 | # ℹ️ Command-line programs to run using the OS shell. 59 | # 📚 https://git.io/JvXDl 60 | 61 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 62 | # and modify them (or add more) to build your code if your project 63 | # uses a compiled language 64 | 65 | #- run: | 66 | # make bootstrap 67 | # make release 68 | 69 | - name: Perform CodeQL Analysis 70 | uses: github/codeql-action/analyze@v1 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /.gradle/ 3 | out/ 4 | build/ 5 | *.iml 6 | *.ipr 7 | *.iws 8 | *.class 9 | test/ 10 | target/ 11 | -------------------------------------------------------------------------------- /Enough java.lang.String to Hang Ourselves ....pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kabutz/string-performance/e568427903a1ae1ea4333a2a64571f9c886638f4/Enough java.lang.String to Hang Ourselves ....pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # string-performance 2 | Set of benchmarks for the "Enough java.lang.String to Hang Ourselves ..." talk 3 | 4 | ## Build 5 | JDK 8 or later is required to build the code. Make sure that your `JAVA_HOME` points to proper JDK release and the run the following command: 6 | ``` 7 | ./gradlew shadowJar 8 | ``` 9 | This will produce a single jar file containing benchmarks: 10 | `build/libs/string-performance-benchmarks-jdk-$javaVersion.jar`, where `$javaVersion` will be replaced with the Java version used to build 11 | the jar (e.g. `string-performance-benchmarks-jdk-11.jar` when built using Java 11). 12 | 13 | ## Run 14 | First build the benchmark jars as described above and then execute them using the following command: 15 | ``` 16 | java -jar 17 | ``` 18 | For example this is how to test JDK 11 code using extra JVM flags to be able to compare JDK 8 with JDK 11: 19 | ``` 20 | java -jar build/libs/string-performance-benchmarks-11.jar -jvmArgs '-Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC' 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java" 3 | id "com.github.ben-manes.versions" version "0.25.0" 4 | id "com.github.johnrengelman.shadow" version "5.1.0" 5 | } 6 | 7 | def javaVersion = JavaVersion.current() // use 6,7,8,11,17 for different versions 8 | sourceCompatibility = javaVersion 9 | targetCompatibility = javaVersion 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation "org.openjdk.jol:jol-core:0.9" 17 | implementation "org.openjdk.jmh:jmh-core:1.12" // to support Java 6 18 | annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:1.12" // to support Java 6 19 | } 20 | 21 | shadowJar { 22 | archiveClassifier = 'benchmarks-jdk-' + javaVersion 23 | manifest { 24 | attributes 'Main-Class': 'org.openjdk.jmh.Main' 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kabutz/string-performance/e568427903a1ae1ea4333a2a64571f9c886638f4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /int2str.sh: -------------------------------------------------------------------------------- 1 | JAVA6=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin 2 | JAVA7=/Library/Java/JavaVirtualMachines/jdk1.7.0.jdk/Contents/Home/bin 3 | JAVA8=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin 4 | JAVA11=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin 5 | 6 | mkdir -p test/j6 test/j7 test/j8 test/j11 7 | 8 | cd src/main/java 9 | echo compiling with Java 6 10 | $JAVA6/javac -d ../../../test/j6 eu/javaspecialists/playground/IntToStringLazy.java eu/javaspecialists/playground/IntToStringStudious.java 11 | echo compiling with Java 7 12 | $JAVA7/javac -d ../../../test/j7 eu/javaspecialists/playground/IntToStringLazy.java eu/javaspecialists/playground/IntToStringStudious.java 13 | echo compiling with Java 8 14 | $JAVA8/javac -d ../../../test/j8 eu/javaspecialists/playground/IntToStringLazy.java eu/javaspecialists/playground/IntToStringStudious.java 15 | echo compiling with Java 11 16 | $JAVA11/javac -d ../../../test/j11 eu/javaspecialists/playground/IntToStringLazy.java eu/javaspecialists/playground/IntToStringStudious.java 17 | 18 | cd ../../.. 19 | 20 | echo out of box comparison 21 | $JAVA6/java -classpath test/j6 eu.javaspecialists.playground/IntToStringLazy 22 | $JAVA6/java -classpath test/j6 eu.javaspecialists.playground/IntToStringStudious 23 | $JAVA7/java -classpath test/j7 eu.javaspecialists.playground/IntToStringLazy 24 | $JAVA7/java -classpath test/j7 eu.javaspecialists.playground/IntToStringStudious 25 | $JAVA8/java -classpath test/j8 eu.javaspecialists.playground/IntToStringLazy 26 | $JAVA8/java -classpath test/j8 eu.javaspecialists.playground/IntToStringStudious 27 | $JAVA11/java -classpath test/j11 eu.javaspecialists.playground/IntToStringLazy 28 | $JAVA11/java -classpath test/j11 eu.javaspecialists.playground/IntToStringStudious 29 | $JAVA11/java -classpath test/j6 eu.javaspecialists.playground/IntToStringLazy 30 | $JAVA11/java -classpath test/j6 eu.javaspecialists.playground/IntToStringStudious 31 | 32 | echo fair comparisons 33 | 34 | $JAVA6/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -classpath test/j6 eu.javaspecialists.playground/IntToStringLazy 35 | $JAVA6/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -classpath test/j6 eu.javaspecialists.playground/IntToStringStudious 36 | $JAVA7/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -classpath test/j7 eu.javaspecialists.playground/IntToStringLazy 37 | $JAVA7/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -classpath test/j7 eu.javaspecialists.playground/IntToStringStudious 38 | $JAVA8/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -classpath test/j8 eu.javaspecialists.playground/IntToStringLazy 39 | $JAVA8/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -classpath test/j8 eu.javaspecialists.playground/IntToStringStudious 40 | $JAVA11/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -classpath test/j11 eu.javaspecialists.playground/IntToStringLazy 41 | $JAVA11/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -classpath test/j11 eu.javaspecialists.playground/IntToStringStudious 42 | $JAVA11/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -XX:-CompactStrings -classpath test/j11 eu.javaspecialists.playground/IntToStringLazy 43 | $JAVA11/java -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -XX:-CompactStrings -classpath test/j11 eu.javaspecialists.playground/IntToStringStudious 44 | 45 | -------------------------------------------------------------------------------- /results/all.csv: -------------------------------------------------------------------------------- 1 | Description Best Fork 1 Fork 2 Fork 3 Fork 4 Fork 5 Fork 6 2 | Lazy: Java 6 JVM, Java 6 Class 4158 4219 4188 4187 4197 4158 4172 3 | Studious: Java 6 JVM, Java 6 Class 3818 3820 3851 3847 3896 3848 3818 4 | Lazy: Java 6 JVM, Java 6 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC 3935 3975 3955 3945 3943 3956 3935 5 | Studious: Java 6 JVM, Java 6 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC 3718 3767 3729 3726 3736 3718 3738 6 | 7 | Lazy: Java 7 JVM, Java 7 Class 2334 2421 2335 2369 2334 2335 2339 8 | Studious: Java 7 JVM, Java 7 Class 2940 2970 2968 2956 2951 2940 2954 9 | Lazy: Java 7 JVM, Java 7 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC 2336 2360 2343 2344 2336 2339 2353 10 | Studious: Java 7 JVM, Java 7 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC 2946 2967 2973 2966 2963 2999 2946 11 | 12 | Lazy: Java 8 JVM, Java 8 Class 2205 2206 2211 2205 2205 2209 2205 13 | Studious: Java 8 JVM, Java 8 Class 3055 3055 3060 3068 3061 3059 3072 14 | Lazy: Java 8 JVM, Java 8 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC 2209 2217 2217 2209 2210 2226 2212 15 | Studious: Java 8 JVM, Java 8 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC 3068 3082 3084 3079 3070 3114 3068 16 | 17 | Lazy: Java 11 JVM, Java 11 Class 1995 2027 2037 2000 1995 2030 2036 18 | Studious: Java 11 JVM, Java 11 Class 2047 2075 2061 2062 2086 2059 2047 19 | Lazy: Java 11 JVM, Java 6 Class 2743 2753 2758 2753 2759 2749 2743 20 | Studious: Java 11 JVM, Java 6 Class 2050 2077 2052 2070 2057 2070 2050 21 | Lazy: Java 11 JVM, Java 11 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC 1616 1668 1686 1624 1681 1722 1616 22 | Studious: Java 11 JVM, Java 11 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC 1764 1817 1765 1764 1788 1786 1817 23 | Lazy: Java 11 JVM, Java 11 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -XX:-CompactStrings 1472 1479 1484 1474 1477 1472 1481 24 | Studious: Java 11 JVM, Java 11 Class, -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -XX:-CompactStrings 1645 1654 1662 1657 1657 1645 1658 25 | -------------------------------------------------------------------------------- /results/int2str1.txt: -------------------------------------------------------------------------------- 1 | compiling with Java 6 2 | compiling with Java 7 3 | compiling with Java 8 4 | compiling with Java 11 5 | out of box comparison 6 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 7 | time = 4219ms 8 | time = 4299ms 9 | time = 4253ms 10 | time = 4335ms 11 | time = 4357ms 12 | time = 4300ms 13 | time = 4244ms 14 | time = 4239ms 15 | time = 4238ms 16 | time = 4237ms 17 | s = 99999999 18 | bestTime = 4219 19 | 20 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 21 | time = 3902ms 22 | time = 3820ms 23 | time = 3975ms 24 | time = 3976ms 25 | time = 3961ms 26 | time = 3955ms 27 | time = 3968ms 28 | time = 3957ms 29 | time = 3941ms 30 | time = 3970ms 31 | s = 99999999 32 | bestTime = 3820 33 | 34 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 35 | time = 2681ms 36 | time = 2421ms 37 | time = 2560ms 38 | time = 2550ms 39 | time = 2623ms 40 | time = 2543ms 41 | time = 2524ms 42 | time = 2548ms 43 | time = 2545ms 44 | time = 2523ms 45 | s = 99999999 46 | bestTime = 2421 47 | 48 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 49 | time = 3337ms 50 | time = 3081ms 51 | time = 2985ms 52 | time = 2970ms 53 | time = 3001ms 54 | time = 2982ms 55 | time = 2995ms 56 | time = 2986ms 57 | time = 2979ms 58 | time = 2985ms 59 | s = 99999999 60 | bestTime = 2970 61 | 62 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 63 | time = 2566ms 64 | time = 2456ms 65 | time = 2251ms 66 | time = 2255ms 67 | time = 2239ms 68 | time = 2251ms 69 | time = 2206ms 70 | time = 2251ms 71 | time = 2222ms 72 | time = 2227ms 73 | s = 99999999 74 | bestTime = 2206 75 | 76 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 77 | time = 3482ms 78 | time = 3055ms 79 | time = 3093ms 80 | time = 3098ms 81 | time = 3091ms 82 | time = 3125ms 83 | time = 3093ms 84 | time = 3111ms 85 | time = 3106ms 86 | time = 3098ms 87 | s = 99999999 88 | bestTime = 3055 89 | 90 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 91 | time = 2027ms 92 | time = 2057ms 93 | time = 2069ms 94 | time = 2030ms 95 | time = 2070ms 96 | time = 2045ms 97 | time = 2030ms 98 | time = 2045ms 99 | time = 2040ms 100 | time = 2062ms 101 | s = 99999999 102 | bestTime = 2027 103 | 104 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 105 | time = 2075ms 106 | time = 2201ms 107 | time = 2251ms 108 | time = 2229ms 109 | time = 2230ms 110 | time = 2263ms 111 | time = 2220ms 112 | time = 2231ms 113 | time = 2243ms 114 | time = 2238ms 115 | s = 99999999 116 | bestTime = 2075 117 | 118 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 119 | time = 2852ms 120 | time = 3067ms 121 | time = 2788ms 122 | time = 2777ms 123 | time = 2776ms 124 | time = 2780ms 125 | time = 2753ms 126 | time = 2759ms 127 | time = 2767ms 128 | time = 2794ms 129 | s = 99999999 130 | bestTime = 2753 131 | 132 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 133 | time = 2077ms 134 | time = 2117ms 135 | time = 2128ms 136 | time = 2121ms 137 | time = 2127ms 138 | time = 2132ms 139 | time = 2126ms 140 | time = 2128ms 141 | time = 2137ms 142 | time = 2135ms 143 | s = 99999999 144 | bestTime = 2077 145 | 146 | fair comparisons 147 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 148 | time = 4114ms 149 | time = 4059ms 150 | time = 3992ms 151 | time = 3988ms 152 | time = 3975ms 153 | time = 4000ms 154 | time = 3988ms 155 | time = 3985ms 156 | time = 3994ms 157 | time = 3975ms 158 | s = 99999999 159 | bestTime = 3975 160 | 161 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 162 | time = 3832ms 163 | time = 3767ms 164 | time = 3889ms 165 | time = 3909ms 166 | time = 3886ms 167 | time = 3866ms 168 | time = 3868ms 169 | time = 4073ms 170 | time = 3920ms 171 | time = 3949ms 172 | s = 99999999 173 | bestTime = 3767 174 | 175 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 176 | time = 2636ms 177 | time = 2360ms 178 | time = 2505ms 179 | time = 2491ms 180 | time = 2504ms 181 | time = 2520ms 182 | time = 2502ms 183 | time = 2521ms 184 | time = 2499ms 185 | time = 2512ms 186 | s = 99999999 187 | bestTime = 2360 188 | 189 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 190 | time = 3335ms 191 | time = 3060ms 192 | time = 2984ms 193 | time = 2999ms 194 | time = 3009ms 195 | time = 2997ms 196 | time = 2967ms 197 | time = 3007ms 198 | time = 2980ms 199 | time = 2994ms 200 | s = 99999999 201 | bestTime = 2967 202 | 203 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 204 | time = 2558ms 205 | time = 2457ms 206 | time = 2217ms 207 | time = 2233ms 208 | time = 2220ms 209 | time = 2251ms 210 | time = 2220ms 211 | time = 2260ms 212 | time = 2218ms 213 | time = 2237ms 214 | s = 99999999 215 | bestTime = 2217 216 | 217 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 218 | time = 3390ms 219 | time = 3163ms 220 | time = 3087ms 221 | time = 3099ms 222 | time = 3110ms 223 | time = 3099ms 224 | time = 3082ms 225 | time = 3095ms 226 | time = 3113ms 227 | time = 3103ms 228 | s = 99999999 229 | bestTime = 3082 230 | 231 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 232 | time = 2038ms 233 | time = 1757ms 234 | time = 1707ms 235 | time = 1683ms 236 | time = 1707ms 237 | time = 1681ms 238 | time = 1710ms 239 | time = 1728ms 240 | time = 1726ms 241 | time = 1668ms 242 | s = 99999999 243 | bestTime = 1668 244 | 245 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 246 | time = 2084ms 247 | time = 1817ms 248 | time = 1835ms 249 | time = 1857ms 250 | time = 1862ms 251 | time = 1843ms 252 | time = 1852ms 253 | time = 1824ms 254 | time = 1861ms 255 | time = 1838ms 256 | s = 99999999 257 | bestTime = 1817 258 | 259 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 260 | time = 1965ms 261 | time = 1563ms 262 | time = 1551ms 263 | time = 1521ms 264 | time = 1513ms 265 | time = 1509ms 266 | time = 1498ms 267 | time = 1489ms 268 | time = 1479ms 269 | time = 1497ms 270 | s = 99999999 271 | bestTime = 1479 272 | 273 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 274 | time = 2011ms 275 | time = 1730ms 276 | time = 1695ms 277 | time = 1698ms 278 | time = 1669ms 279 | time = 1656ms 280 | time = 1654ms 281 | time = 1687ms 282 | time = 1676ms 283 | time = 1678ms 284 | s = 99999999 285 | bestTime = 1654 286 | 287 | -------------------------------------------------------------------------------- /results/int2str2.txt: -------------------------------------------------------------------------------- 1 | compiling with Java 6 2 | compiling with Java 7 3 | compiling with Java 8 4 | compiling with Java 11 5 | out of box comparison 6 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 7 | time = 4207ms 8 | time = 4296ms 9 | time = 4215ms 10 | time = 4210ms 11 | time = 4221ms 12 | time = 4195ms 13 | time = 4199ms 14 | time = 4200ms 15 | time = 4204ms 16 | time = 4188ms 17 | s = 99999999 18 | bestTime = 4188 19 | 20 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 21 | time = 3915ms 22 | time = 3851ms 23 | time = 4013ms 24 | time = 4030ms 25 | time = 4013ms 26 | time = 4040ms 27 | time = 4021ms 28 | time = 4014ms 29 | time = 4007ms 30 | time = 4054ms 31 | s = 99999999 32 | bestTime = 3851 33 | 34 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 35 | time = 2611ms 36 | time = 2335ms 37 | time = 2508ms 38 | time = 2493ms 39 | time = 2502ms 40 | time = 2503ms 41 | time = 2490ms 42 | time = 2504ms 43 | time = 2500ms 44 | time = 2520ms 45 | s = 99999999 46 | bestTime = 2335 47 | 48 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 49 | time = 3323ms 50 | time = 3090ms 51 | time = 3020ms 52 | time = 3015ms 53 | time = 2968ms 54 | time = 2980ms 55 | time = 2988ms 56 | time = 2975ms 57 | time = 2981ms 58 | time = 3015ms 59 | s = 99999999 60 | bestTime = 2968 61 | 62 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 63 | time = 2559ms 64 | time = 2441ms 65 | time = 2248ms 66 | time = 2229ms 67 | time = 2238ms 68 | time = 2224ms 69 | time = 2234ms 70 | time = 2242ms 71 | time = 2213ms 72 | time = 2211ms 73 | s = 99999999 74 | bestTime = 2211 75 | 76 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 77 | time = 3516ms 78 | time = 3094ms 79 | time = 3067ms 80 | time = 3071ms 81 | time = 3068ms 82 | time = 3060ms 83 | time = 3083ms 84 | time = 3090ms 85 | time = 3089ms 86 | time = 3077ms 87 | s = 99999999 88 | bestTime = 3060 89 | 90 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 91 | time = 2037ms 92 | time = 2073ms 93 | time = 2096ms 94 | time = 2087ms 95 | time = 2080ms 96 | time = 2078ms 97 | time = 2092ms 98 | time = 2071ms 99 | time = 2084ms 100 | time = 2089ms 101 | s = 99999999 102 | bestTime = 2037 103 | 104 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 105 | time = 2061ms 106 | time = 2129ms 107 | time = 2121ms 108 | time = 2139ms 109 | time = 2151ms 110 | time = 2148ms 111 | time = 2134ms 112 | time = 2152ms 113 | time = 2135ms 114 | time = 2212ms 115 | s = 99999999 116 | bestTime = 2061 117 | 118 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 119 | time = 2864ms 120 | time = 3083ms 121 | time = 2784ms 122 | time = 2785ms 123 | time = 2794ms 124 | time = 2801ms 125 | time = 2762ms 126 | time = 2783ms 127 | time = 2767ms 128 | time = 2758ms 129 | s = 99999999 130 | bestTime = 2758 131 | 132 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 133 | time = 2052ms 134 | time = 2145ms 135 | time = 2146ms 136 | time = 2137ms 137 | time = 2148ms 138 | time = 2164ms 139 | time = 2176ms 140 | time = 2171ms 141 | time = 2143ms 142 | time = 2114ms 143 | s = 99999999 144 | bestTime = 2052 145 | 146 | fair comparisons 147 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 148 | time = 4117ms 149 | time = 4026ms 150 | time = 3966ms 151 | time = 3969ms 152 | time = 3995ms 153 | time = 3959ms 154 | time = 3967ms 155 | time = 3987ms 156 | time = 3982ms 157 | time = 3955ms 158 | s = 99999999 159 | bestTime = 3955 160 | 161 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 162 | time = 3836ms 163 | time = 3729ms 164 | time = 3877ms 165 | time = 3907ms 166 | time = 3881ms 167 | time = 3899ms 168 | time = 3924ms 169 | time = 3900ms 170 | time = 3870ms 171 | time = 3854ms 172 | s = 99999999 173 | bestTime = 3729 174 | 175 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 176 | time = 2619ms 177 | time = 2343ms 178 | time = 2488ms 179 | time = 2504ms 180 | time = 2523ms 181 | time = 2507ms 182 | time = 2568ms 183 | time = 2507ms 184 | time = 2580ms 185 | time = 2482ms 186 | s = 99999999 187 | bestTime = 2343 188 | 189 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 190 | time = 3401ms 191 | time = 3068ms 192 | time = 3010ms 193 | time = 2988ms 194 | time = 2992ms 195 | time = 2973ms 196 | time = 2979ms 197 | time = 2985ms 198 | time = 2983ms 199 | time = 3007ms 200 | s = 99999999 201 | bestTime = 2973 202 | 203 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 204 | time = 2546ms 205 | time = 2460ms 206 | time = 2234ms 207 | time = 2217ms 208 | time = 2221ms 209 | time = 2224ms 210 | time = 2220ms 211 | time = 2224ms 212 | time = 2231ms 213 | time = 2230ms 214 | s = 99999999 215 | bestTime = 2217 216 | 217 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 218 | time = 3492ms 219 | time = 3182ms 220 | time = 3114ms 221 | time = 3093ms 222 | time = 3103ms 223 | time = 3100ms 224 | time = 3084ms 225 | time = 3084ms 226 | time = 3092ms 227 | time = 3116ms 228 | s = 99999999 229 | bestTime = 3084 230 | 231 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 232 | time = 1898ms 233 | time = 1754ms 234 | time = 1722ms 235 | time = 1696ms 236 | time = 1699ms 237 | time = 1704ms 238 | time = 1693ms 239 | time = 1686ms 240 | time = 1693ms 241 | time = 1692ms 242 | s = 99999999 243 | bestTime = 1686 244 | 245 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 246 | time = 2055ms 247 | time = 1765ms 248 | time = 1799ms 249 | time = 1796ms 250 | time = 1840ms 251 | time = 1814ms 252 | time = 1822ms 253 | time = 1828ms 254 | time = 1815ms 255 | time = 1799ms 256 | s = 99999999 257 | bestTime = 1765 258 | 259 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 260 | time = 1973ms 261 | time = 1568ms 262 | time = 1537ms 263 | time = 1527ms 264 | time = 1503ms 265 | time = 1488ms 266 | time = 1489ms 267 | time = 1489ms 268 | time = 1484ms 269 | time = 1495ms 270 | s = 99999999 271 | bestTime = 1484 272 | 273 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 274 | time = 2021ms 275 | time = 1732ms 276 | time = 1712ms 277 | time = 1694ms 278 | time = 1687ms 279 | time = 1663ms 280 | time = 1662ms 281 | time = 1675ms 282 | time = 1674ms 283 | time = 1684ms 284 | s = 99999999 285 | bestTime = 1662 286 | 287 | -------------------------------------------------------------------------------- /results/int2str3.txt: -------------------------------------------------------------------------------- 1 | compiling with Java 6 2 | compiling with Java 7 3 | compiling with Java 8 4 | compiling with Java 11 5 | out of box comparison 6 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 7 | time = 4195ms 8 | time = 4251ms 9 | time = 4201ms 10 | time = 4190ms 11 | time = 4187ms 12 | time = 4194ms 13 | time = 4187ms 14 | time = 4197ms 15 | time = 4197ms 16 | time = 4196ms 17 | s = 99999999 18 | bestTime = 4187 19 | 20 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 21 | time = 3950ms 22 | time = 3847ms 23 | time = 3920ms 24 | time = 3928ms 25 | time = 3956ms 26 | time = 3955ms 27 | time = 3949ms 28 | time = 3943ms 29 | time = 3892ms 30 | time = 3952ms 31 | s = 99999999 32 | bestTime = 3847 33 | 34 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 35 | time = 2611ms 36 | time = 2369ms 37 | time = 2488ms 38 | time = 2493ms 39 | time = 2521ms 40 | time = 2502ms 41 | time = 2517ms 42 | time = 2508ms 43 | time = 2523ms 44 | time = 2505ms 45 | s = 99999999 46 | bestTime = 2369 47 | 48 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 49 | time = 3285ms 50 | time = 3064ms 51 | time = 2969ms 52 | time = 2969ms 53 | time = 2968ms 54 | time = 2963ms 55 | time = 2956ms 56 | time = 2982ms 57 | time = 2974ms 58 | time = 2999ms 59 | s = 99999999 60 | bestTime = 2956 61 | 62 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 63 | time = 2675ms 64 | time = 2429ms 65 | time = 2225ms 66 | time = 2222ms 67 | time = 2224ms 68 | time = 2205ms 69 | time = 2229ms 70 | time = 2231ms 71 | time = 2239ms 72 | time = 2205ms 73 | s = 99999999 74 | bestTime = 2205 75 | 76 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 77 | time = 3513ms 78 | time = 3113ms 79 | time = 3082ms 80 | time = 3080ms 81 | time = 3082ms 82 | time = 3109ms 83 | time = 3086ms 84 | time = 3074ms 85 | time = 3094ms 86 | time = 3068ms 87 | s = 99999999 88 | bestTime = 3068 89 | 90 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 91 | time = 2000ms 92 | time = 2064ms 93 | time = 2042ms 94 | time = 2035ms 95 | time = 2050ms 96 | time = 2054ms 97 | time = 2029ms 98 | time = 2028ms 99 | time = 2020ms 100 | time = 2062ms 101 | s = 99999999 102 | bestTime = 2000 103 | 104 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 105 | time = 2062ms 106 | time = 2116ms 107 | time = 2139ms 108 | time = 2146ms 109 | time = 2150ms 110 | time = 2120ms 111 | time = 2127ms 112 | time = 2132ms 113 | time = 2145ms 114 | time = 2134ms 115 | s = 99999999 116 | bestTime = 2062 117 | 118 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 119 | time = 2869ms 120 | time = 3058ms 121 | time = 2753ms 122 | time = 2771ms 123 | time = 2768ms 124 | time = 2770ms 125 | time = 2787ms 126 | time = 2762ms 127 | time = 2787ms 128 | time = 2763ms 129 | s = 99999999 130 | bestTime = 2753 131 | 132 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 133 | time = 2070ms 134 | time = 2134ms 135 | time = 2131ms 136 | time = 2130ms 137 | time = 2122ms 138 | time = 2121ms 139 | time = 2139ms 140 | time = 2121ms 141 | time = 2154ms 142 | time = 2130ms 143 | s = 99999999 144 | bestTime = 2070 145 | 146 | fair comparisons 147 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 148 | time = 4252ms 149 | time = 4053ms 150 | time = 3972ms 151 | time = 3992ms 152 | time = 3962ms 153 | time = 3945ms 154 | time = 3963ms 155 | time = 4009ms 156 | time = 3967ms 157 | time = 3971ms 158 | s = 99999999 159 | bestTime = 3945 160 | 161 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 162 | time = 3839ms 163 | time = 3726ms 164 | time = 3839ms 165 | time = 3862ms 166 | time = 3860ms 167 | time = 3884ms 168 | time = 3857ms 169 | time = 3866ms 170 | time = 3861ms 171 | time = 3856ms 172 | s = 99999999 173 | bestTime = 3726 174 | 175 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 176 | time = 2604ms 177 | time = 2344ms 178 | time = 2500ms 179 | time = 2491ms 180 | time = 2479ms 181 | time = 2509ms 182 | time = 2490ms 183 | time = 2499ms 184 | time = 2485ms 185 | time = 2511ms 186 | s = 99999999 187 | bestTime = 2344 188 | 189 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 190 | time = 3329ms 191 | time = 3075ms 192 | time = 2989ms 193 | time = 2966ms 194 | time = 3000ms 195 | time = 2983ms 196 | time = 2975ms 197 | time = 2986ms 198 | time = 2980ms 199 | time = 2987ms 200 | s = 99999999 201 | bestTime = 2966 202 | 203 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 204 | time = 2690ms 205 | time = 2448ms 206 | time = 2209ms 207 | time = 2229ms 208 | time = 2212ms 209 | time = 2222ms 210 | time = 2227ms 211 | time = 2227ms 212 | time = 2230ms 213 | time = 2231ms 214 | s = 99999999 215 | bestTime = 2209 216 | 217 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 218 | time = 3470ms 219 | time = 3197ms 220 | time = 3086ms 221 | time = 3122ms 222 | time = 3088ms 223 | time = 3094ms 224 | time = 3082ms 225 | time = 3086ms 226 | time = 3101ms 227 | time = 3079ms 228 | s = 99999999 229 | bestTime = 3079 230 | 231 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 232 | time = 2018ms 233 | time = 1671ms 234 | time = 1638ms 235 | time = 1643ms 236 | time = 1646ms 237 | time = 1645ms 238 | time = 1627ms 239 | time = 1642ms 240 | time = 1632ms 241 | time = 1624ms 242 | s = 99999999 243 | bestTime = 1624 244 | 245 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 246 | time = 2051ms 247 | time = 1764ms 248 | time = 1798ms 249 | time = 1806ms 250 | time = 1811ms 251 | time = 1823ms 252 | time = 1820ms 253 | time = 1811ms 254 | time = 1819ms 255 | time = 1803ms 256 | s = 99999999 257 | bestTime = 1764 258 | 259 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 260 | time = 1953ms 261 | time = 1550ms 262 | time = 1526ms 263 | time = 1517ms 264 | time = 1482ms 265 | time = 1494ms 266 | time = 1487ms 267 | time = 1474ms 268 | time = 1493ms 269 | time = 1505ms 270 | s = 99999999 271 | bestTime = 1474 272 | 273 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 274 | time = 2021ms 275 | time = 1739ms 276 | time = 1686ms 277 | time = 1688ms 278 | time = 1657ms 279 | time = 1671ms 280 | time = 1699ms 281 | time = 1683ms 282 | time = 1664ms 283 | time = 1665ms 284 | s = 99999999 285 | bestTime = 1657 286 | 287 | -------------------------------------------------------------------------------- /results/int2str4.txt: -------------------------------------------------------------------------------- 1 | compiling with Java 6 2 | compiling with Java 7 3 | compiling with Java 8 4 | compiling with Java 11 5 | out of box comparison 6 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 7 | time = 4207ms 8 | time = 4268ms 9 | time = 4204ms 10 | time = 4211ms 11 | time = 4197ms 12 | time = 4200ms 13 | time = 4202ms 14 | time = 4198ms 15 | time = 4208ms 16 | time = 4203ms 17 | s = 99999999 18 | bestTime = 4197 19 | 20 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 21 | time = 3945ms 22 | time = 3896ms 23 | time = 4024ms 24 | time = 4020ms 25 | time = 4048ms 26 | time = 4034ms 27 | time = 3991ms 28 | time = 4044ms 29 | time = 4024ms 30 | time = 4059ms 31 | s = 99999999 32 | bestTime = 3896 33 | 34 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 35 | time = 2606ms 36 | time = 2334ms 37 | time = 2497ms 38 | time = 2503ms 39 | time = 2482ms 40 | time = 2483ms 41 | time = 2494ms 42 | time = 2500ms 43 | time = 2492ms 44 | time = 2487ms 45 | s = 99999999 46 | bestTime = 2334 47 | 48 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 49 | time = 3336ms 50 | time = 3076ms 51 | time = 2966ms 52 | time = 2965ms 53 | time = 2956ms 54 | time = 2966ms 55 | time = 2965ms 56 | time = 2966ms 57 | time = 2976ms 58 | time = 2951ms 59 | s = 99999999 60 | bestTime = 2951 61 | 62 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 63 | time = 2538ms 64 | time = 2436ms 65 | time = 2225ms 66 | time = 2238ms 67 | time = 2229ms 68 | time = 2220ms 69 | time = 2209ms 70 | time = 2222ms 71 | time = 2205ms 72 | time = 2219ms 73 | s = 99999999 74 | bestTime = 2205 75 | 76 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 77 | time = 3481ms 78 | time = 3082ms 79 | time = 3098ms 80 | time = 3061ms 81 | time = 3079ms 82 | time = 3076ms 83 | time = 3080ms 84 | time = 3089ms 85 | time = 3082ms 86 | time = 3094ms 87 | s = 99999999 88 | bestTime = 3061 89 | 90 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 91 | time = 2018ms 92 | time = 2079ms 93 | time = 2016ms 94 | time = 1995ms 95 | time = 2016ms 96 | time = 2004ms 97 | time = 2010ms 98 | time = 1998ms 99 | time = 2011ms 100 | time = 2022ms 101 | s = 99999999 102 | bestTime = 1995 103 | 104 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 105 | time = 2086ms 106 | time = 2108ms 107 | time = 2141ms 108 | time = 2125ms 109 | time = 2134ms 110 | time = 2125ms 111 | time = 2139ms 112 | time = 2132ms 113 | time = 2137ms 114 | time = 2141ms 115 | s = 99999999 116 | bestTime = 2086 117 | 118 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 119 | time = 2872ms 120 | time = 3036ms 121 | time = 2759ms 122 | time = 2775ms 123 | time = 2761ms 124 | time = 2777ms 125 | time = 2764ms 126 | time = 2774ms 127 | time = 2762ms 128 | time = 2773ms 129 | s = 99999999 130 | bestTime = 2759 131 | 132 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 133 | time = 2057ms 134 | time = 2104ms 135 | time = 2113ms 136 | time = 2115ms 137 | time = 2121ms 138 | time = 2121ms 139 | time = 2140ms 140 | time = 2134ms 141 | time = 2128ms 142 | time = 2124ms 143 | s = 99999999 144 | bestTime = 2057 145 | 146 | fair comparisons 147 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 148 | time = 4085ms 149 | time = 4006ms 150 | time = 3960ms 151 | time = 3956ms 152 | time = 3954ms 153 | time = 3954ms 154 | time = 3943ms 155 | time = 3955ms 156 | time = 3950ms 157 | time = 3978ms 158 | s = 99999999 159 | bestTime = 3943 160 | 161 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 162 | time = 3806ms 163 | time = 3736ms 164 | time = 3859ms 165 | time = 3861ms 166 | time = 3884ms 167 | time = 3861ms 168 | time = 3873ms 169 | time = 3847ms 170 | time = 3864ms 171 | time = 3834ms 172 | s = 99999999 173 | bestTime = 3736 174 | 175 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 176 | time = 2593ms 177 | time = 2336ms 178 | time = 2513ms 179 | time = 2508ms 180 | time = 2495ms 181 | time = 2505ms 182 | time = 2502ms 183 | time = 2510ms 184 | time = 2499ms 185 | time = 2499ms 186 | s = 99999999 187 | bestTime = 2336 188 | 189 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 190 | time = 3361ms 191 | time = 3062ms 192 | time = 2968ms 193 | time = 2972ms 194 | time = 2963ms 195 | time = 2971ms 196 | time = 2969ms 197 | time = 2969ms 198 | time = 2968ms 199 | time = 2964ms 200 | s = 99999999 201 | bestTime = 2963 202 | 203 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 204 | time = 2673ms 205 | time = 2439ms 206 | time = 2221ms 207 | time = 2219ms 208 | time = 2217ms 209 | time = 2220ms 210 | time = 2229ms 211 | time = 2219ms 212 | time = 2210ms 213 | time = 2219ms 214 | s = 99999999 215 | bestTime = 2210 216 | 217 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 218 | time = 3429ms 219 | time = 3166ms 220 | time = 3102ms 221 | time = 3095ms 222 | time = 3071ms 223 | time = 3070ms 224 | time = 3075ms 225 | time = 3095ms 226 | time = 3087ms 227 | time = 3086ms 228 | s = 99999999 229 | bestTime = 3070 230 | 231 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 232 | time = 1895ms 233 | time = 1756ms 234 | time = 1713ms 235 | time = 1693ms 236 | time = 1696ms 237 | time = 1686ms 238 | time = 1681ms 239 | time = 1692ms 240 | time = 1696ms 241 | time = 1682ms 242 | s = 99999999 243 | bestTime = 1681 244 | 245 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 246 | time = 2061ms 247 | time = 1788ms 248 | time = 1796ms 249 | time = 1800ms 250 | time = 1814ms 251 | time = 1801ms 252 | time = 1801ms 253 | time = 1849ms 254 | time = 1815ms 255 | time = 1806ms 256 | s = 99999999 257 | bestTime = 1788 258 | 259 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 260 | time = 1986ms 261 | time = 1552ms 262 | time = 1516ms 263 | time = 1533ms 264 | time = 1477ms 265 | time = 1488ms 266 | time = 1477ms 267 | time = 1531ms 268 | time = 1477ms 269 | time = 1485ms 270 | s = 99999999 271 | bestTime = 1477 272 | 273 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 274 | time = 2010ms 275 | time = 1715ms 276 | time = 1698ms 277 | time = 1706ms 278 | time = 1660ms 279 | time = 1674ms 280 | time = 1667ms 281 | time = 1667ms 282 | time = 1670ms 283 | time = 1657ms 284 | s = 99999999 285 | bestTime = 1657 286 | 287 | -------------------------------------------------------------------------------- /results/int2str5.txt: -------------------------------------------------------------------------------- 1 | compiling with Java 6 2 | compiling with Java 7 3 | compiling with Java 8 4 | compiling with Java 11 5 | out of box comparison 6 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 7 | time = 4158ms 8 | time = 4240ms 9 | time = 4173ms 10 | time = 4179ms 11 | time = 4184ms 12 | time = 4171ms 13 | time = 4166ms 14 | time = 4168ms 15 | time = 4187ms 16 | time = 4167ms 17 | s = 99999999 18 | bestTime = 4158 19 | 20 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 21 | time = 3950ms 22 | time = 3848ms 23 | time = 4013ms 24 | time = 4015ms 25 | time = 4078ms 26 | time = 4022ms 27 | time = 4058ms 28 | time = 3970ms 29 | time = 4042ms 30 | time = 4060ms 31 | s = 99999999 32 | bestTime = 3848 33 | 34 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 35 | time = 2625ms 36 | time = 2335ms 37 | time = 2497ms 38 | time = 2496ms 39 | time = 2478ms 40 | time = 2487ms 41 | time = 2507ms 42 | time = 2494ms 43 | time = 2488ms 44 | time = 2482ms 45 | s = 99999999 46 | bestTime = 2335 47 | 48 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 49 | time = 3295ms 50 | time = 3122ms 51 | time = 2984ms 52 | time = 2999ms 53 | time = 2987ms 54 | time = 2971ms 55 | time = 2972ms 56 | time = 2940ms 57 | time = 2952ms 58 | time = 2963ms 59 | s = 99999999 60 | bestTime = 2940 61 | 62 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 63 | time = 2672ms 64 | time = 2441ms 65 | time = 2244ms 66 | time = 2215ms 67 | time = 2228ms 68 | time = 2209ms 69 | time = 2221ms 70 | time = 2218ms 71 | time = 2215ms 72 | time = 2212ms 73 | s = 99999999 74 | bestTime = 2209 75 | 76 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 77 | time = 3508ms 78 | time = 3066ms 79 | time = 3087ms 80 | time = 3079ms 81 | time = 3117ms 82 | time = 3092ms 83 | time = 3078ms 84 | time = 3082ms 85 | time = 3103ms 86 | time = 3059ms 87 | s = 99999999 88 | bestTime = 3059 89 | 90 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 91 | time = 2030ms 92 | time = 2072ms 93 | time = 2076ms 94 | time = 2053ms 95 | time = 2070ms 96 | time = 2066ms 97 | time = 2050ms 98 | time = 2057ms 99 | time = 2054ms 100 | time = 2041ms 101 | s = 99999999 102 | bestTime = 2030 103 | 104 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 105 | time = 2059ms 106 | time = 2117ms 107 | time = 2135ms 108 | time = 2117ms 109 | time = 2115ms 110 | time = 2138ms 111 | time = 2147ms 112 | time = 2134ms 113 | time = 2128ms 114 | time = 2139ms 115 | s = 99999999 116 | bestTime = 2059 117 | 118 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 119 | time = 2863ms 120 | time = 3026ms 121 | time = 2773ms 122 | time = 2766ms 123 | time = 2775ms 124 | time = 2749ms 125 | time = 2762ms 126 | time = 2778ms 127 | time = 2782ms 128 | time = 2806ms 129 | s = 99999999 130 | bestTime = 2749 131 | 132 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 133 | time = 2070ms 134 | time = 2137ms 135 | time = 2157ms 136 | time = 2143ms 137 | time = 2133ms 138 | time = 2171ms 139 | time = 2118ms 140 | time = 2138ms 141 | time = 2109ms 142 | time = 2124ms 143 | s = 99999999 144 | bestTime = 2070 145 | 146 | fair comparisons 147 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 148 | time = 4096ms 149 | time = 4007ms 150 | time = 3975ms 151 | time = 3976ms 152 | time = 3985ms 153 | time = 3968ms 154 | time = 3956ms 155 | time = 3963ms 156 | time = 3974ms 157 | time = 3973ms 158 | s = 99999999 159 | bestTime = 3956 160 | 161 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 162 | time = 3860ms 163 | time = 3718ms 164 | time = 3867ms 165 | time = 3860ms 166 | time = 3866ms 167 | time = 3840ms 168 | time = 3873ms 169 | time = 3845ms 170 | time = 3843ms 171 | time = 3860ms 172 | s = 99999999 173 | bestTime = 3718 174 | 175 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 176 | time = 2623ms 177 | time = 2339ms 178 | time = 2511ms 179 | time = 2504ms 180 | time = 2518ms 181 | time = 2513ms 182 | time = 2492ms 183 | time = 2501ms 184 | time = 2486ms 185 | time = 2484ms 186 | s = 99999999 187 | bestTime = 2339 188 | 189 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 190 | time = 3347ms 191 | time = 3064ms 192 | time = 2999ms 193 | time = 3013ms 194 | time = 3116ms 195 | time = 3031ms 196 | time = 3020ms 197 | time = 3054ms 198 | time = 3044ms 199 | time = 3029ms 200 | s = 99999999 201 | bestTime = 2999 202 | 203 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 204 | time = 2643ms 205 | time = 2553ms 206 | time = 2331ms 207 | time = 2360ms 208 | time = 2341ms 209 | time = 2271ms 210 | time = 2296ms 211 | time = 2226ms 212 | time = 2250ms 213 | time = 2229ms 214 | s = 99999999 215 | bestTime = 2226 216 | 217 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 218 | time = 3406ms 219 | time = 3194ms 220 | time = 3117ms 221 | time = 3114ms 222 | time = 3120ms 223 | time = 3192ms 224 | time = 3225ms 225 | time = 3225ms 226 | time = 3193ms 227 | time = 3201ms 228 | s = 99999999 229 | bestTime = 3114 230 | 231 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 232 | time = 1984ms 233 | time = 1775ms 234 | time = 1781ms 235 | time = 1769ms 236 | time = 1722ms 237 | time = 1757ms 238 | time = 1774ms 239 | time = 1767ms 240 | time = 1767ms 241 | time = 1746ms 242 | s = 99999999 243 | bestTime = 1722 244 | 245 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 246 | time = 2184ms 247 | time = 1883ms 248 | time = 1913ms 249 | time = 1893ms 250 | time = 1799ms 251 | time = 1786ms 252 | time = 1817ms 253 | time = 1814ms 254 | time = 1804ms 255 | time = 1794ms 256 | s = 99999999 257 | bestTime = 1786 258 | 259 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 260 | time = 1950ms 261 | time = 1563ms 262 | time = 1513ms 263 | time = 1506ms 264 | time = 1477ms 265 | time = 1479ms 266 | time = 1484ms 267 | time = 1485ms 268 | time = 1472ms 269 | time = 1508ms 270 | s = 99999999 271 | bestTime = 1472 272 | 273 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 274 | time = 2006ms 275 | time = 1726ms 276 | time = 1698ms 277 | time = 1668ms 278 | time = 1645ms 279 | time = 1654ms 280 | time = 1653ms 281 | time = 1656ms 282 | time = 1668ms 283 | time = 1668ms 284 | s = 99999999 285 | bestTime = 1645 286 | 287 | -------------------------------------------------------------------------------- /results/int2str6.txt: -------------------------------------------------------------------------------- 1 | compiling with Java 6 2 | compiling with Java 7 3 | compiling with Java 8 4 | compiling with Java 11 5 | out of box comparison 6 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 7 | time = 4172ms 8 | time = 4244ms 9 | time = 4174ms 10 | time = 4184ms 11 | time = 4189ms 12 | time = 4180ms 13 | time = 4192ms 14 | time = 4184ms 15 | time = 4180ms 16 | time = 4184ms 17 | s = 99999999 18 | bestTime = 4172 19 | 20 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [] 21 | time = 3877ms 22 | time = 3818ms 23 | time = 4004ms 24 | time = 3982ms 25 | time = 4018ms 26 | time = 3989ms 27 | time = 3987ms 28 | time = 3987ms 29 | time = 3963ms 30 | time = 3972ms 31 | s = 99999999 32 | bestTime = 3818 33 | 34 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 35 | time = 2607ms 36 | time = 2339ms 37 | time = 2479ms 38 | time = 2497ms 39 | time = 2503ms 40 | time = 2498ms 41 | time = 2484ms 42 | time = 2494ms 43 | time = 2489ms 44 | time = 2479ms 45 | s = 99999999 46 | bestTime = 2339 47 | 48 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [] 49 | time = 3297ms 50 | time = 3055ms 51 | time = 2975ms 52 | time = 2974ms 53 | time = 3002ms 54 | time = 3001ms 55 | time = 3004ms 56 | time = 2960ms 57 | time = 2954ms 58 | time = 2970ms 59 | s = 99999999 60 | bestTime = 2954 61 | 62 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 63 | time = 2543ms 64 | time = 2453ms 65 | time = 2210ms 66 | time = 2216ms 67 | time = 2214ms 68 | time = 2207ms 69 | time = 2208ms 70 | time = 2235ms 71 | time = 2205ms 72 | time = 2217ms 73 | s = 99999999 74 | bestTime = 2205 75 | 76 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [] 77 | time = 3487ms 78 | time = 3077ms 79 | time = 3103ms 80 | time = 3076ms 81 | time = 3074ms 82 | time = 3072ms 83 | time = 3120ms 84 | time = 3114ms 85 | time = 3102ms 86 | time = 3081ms 87 | s = 99999999 88 | bestTime = 3072 89 | 90 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 91 | time = 2064ms 92 | time = 2067ms 93 | time = 2056ms 94 | time = 2036ms 95 | time = 2045ms 96 | time = 2062ms 97 | time = 2064ms 98 | time = 2041ms 99 | time = 2042ms 100 | time = 2050ms 101 | s = 99999999 102 | bestTime = 2036 103 | 104 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 105 | time = 2047ms 106 | time = 2114ms 107 | time = 2116ms 108 | time = 2113ms 109 | time = 2140ms 110 | time = 2121ms 111 | time = 2127ms 112 | time = 2114ms 113 | time = 2121ms 114 | time = 2114ms 115 | s = 99999999 116 | bestTime = 2047 117 | 118 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 119 | time = 2837ms 120 | time = 3038ms 121 | time = 2758ms 122 | time = 2761ms 123 | time = 2758ms 124 | time = 2762ms 125 | time = 2754ms 126 | time = 2764ms 127 | time = 2751ms 128 | time = 2743ms 129 | s = 99999999 130 | bestTime = 2743 131 | 132 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [] 133 | time = 2050ms 134 | time = 2113ms 135 | time = 2117ms 136 | time = 2113ms 137 | time = 2119ms 138 | time = 2122ms 139 | time = 2117ms 140 | time = 2096ms 141 | time = 2130ms 142 | time = 2096ms 143 | s = 99999999 144 | bestTime = 2050 145 | 146 | fair comparisons 147 | IntToStringLazy on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 148 | time = 4110ms 149 | time = 4014ms 150 | time = 3974ms 151 | time = 3951ms 152 | time = 3939ms 153 | time = 3935ms 154 | time = 3943ms 155 | time = 3941ms 156 | time = 3972ms 157 | time = 3948ms 158 | s = 99999999 159 | bestTime = 3935 160 | 161 | IntToStringStudious on Apple Inc., Java HotSpot(TM) 64-Bit Server VM, Java 20.65-b04-468 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 162 | time = 3859ms 163 | time = 3738ms 164 | time = 3824ms 165 | time = 3811ms 166 | time = 3812ms 167 | time = 3842ms 168 | time = 3825ms 169 | time = 3828ms 170 | time = 3817ms 171 | time = 3834ms 172 | s = 99999999 173 | bestTime = 3738 174 | 175 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 176 | time = 2605ms 177 | time = 2353ms 178 | time = 2495ms 179 | time = 2486ms 180 | time = 2493ms 181 | time = 2485ms 182 | time = 2496ms 183 | time = 2500ms 184 | time = 2485ms 185 | time = 2508ms 186 | s = 99999999 187 | bestTime = 2353 188 | 189 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 24.80-b11 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 190 | time = 3307ms 191 | time = 3064ms 192 | time = 2961ms 193 | time = 2962ms 194 | time = 2968ms 195 | time = 2946ms 196 | time = 2964ms 197 | time = 2968ms 198 | time = 2981ms 199 | time = 3000ms 200 | s = 99999999 201 | bestTime = 2946 202 | 203 | IntToStringLazy on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 204 | time = 2526ms 205 | time = 2464ms 206 | time = 2217ms 207 | time = 2219ms 208 | time = 2242ms 209 | time = 2220ms 210 | time = 2228ms 211 | time = 2234ms 212 | time = 2212ms 213 | time = 2230ms 214 | s = 99999999 215 | bestTime = 2212 216 | 217 | IntToStringStudious on Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM, Java 25.181-b13 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 218 | time = 3471ms 219 | time = 3161ms 220 | time = 3086ms 221 | time = 3071ms 222 | time = 3072ms 223 | time = 3080ms 224 | time = 3097ms 225 | time = 3080ms 226 | time = 3068ms 227 | time = 3099ms 228 | s = 99999999 229 | bestTime = 3068 230 | 231 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 232 | time = 1998ms 233 | time = 1684ms 234 | time = 1639ms 235 | time = 1625ms 236 | time = 1623ms 237 | time = 1616ms 238 | time = 1637ms 239 | time = 1622ms 240 | time = 1628ms 241 | time = 1626ms 242 | s = 99999999 243 | bestTime = 1616 244 | 245 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC] 246 | time = 2074ms 247 | time = 1817ms 248 | time = 1847ms 249 | time = 1835ms 250 | time = 1822ms 251 | time = 1843ms 252 | time = 1822ms 253 | time = 1855ms 254 | time = 1845ms 255 | time = 1848ms 256 | s = 99999999 257 | bestTime = 1817 258 | 259 | IntToStringLazy on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 260 | time = 1990ms 261 | time = 1571ms 262 | time = 1525ms 263 | time = 1506ms 264 | time = 1495ms 265 | time = 1482ms 266 | time = 1492ms 267 | time = 1481ms 268 | time = 1493ms 269 | time = 1493ms 270 | s = 99999999 271 | bestTime = 1481 272 | 273 | IntToStringStudious on Oracle Corporation, OpenJDK 64-Bit Server VM, Java 11+28 : vm args [-Xmx8g, -XX:-TieredCompilation, -XX:+UseParallelGC, -XX:-CompactStrings] 274 | time = 2012ms 275 | time = 1727ms 276 | time = 1692ms 277 | time = 1701ms 278 | time = 1685ms 279 | time = 1666ms 280 | time = 1688ms 281 | time = 1664ms 282 | time = 1687ms 283 | time = 1658ms 284 | s = 99999999 285 | bestTime = 1658 286 | 287 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/java-jdk17-nocompact2021-10-22-11-46.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 17, VM 17+35-2724 3 | # VM invoker: /opt/jdk-17/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:-CompactStrings -XX:+UseParallelGC 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_1_plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:11:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 72.454 ns/op 15 | # Warmup Iteration 2: 67.320 ns/op 16 | # Warmup Iteration 3: 66.217 ns/op 17 | # Warmup Iteration 4: 66.760 ns/op 18 | # Warmup Iteration 5: 66.478 ns/op 19 | Iteration 1: 67.431 ns/op 20 | Iteration 2: 66.374 ns/op 21 | Iteration 3: 66.609 ns/op 22 | Iteration 4: 66.390 ns/op 23 | Iteration 5: 66.751 ns/op 24 | Iteration 6: 66.638 ns/op 25 | Iteration 7: 66.498 ns/op 26 | Iteration 8: 66.322 ns/op 27 | Iteration 9: 66.463 ns/op 28 | Iteration 10: 66.661 ns/op 29 | 30 | # Run progress: 6.67% complete, ETA 00:10:34 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 88.066 ns/op 33 | # Warmup Iteration 2: 81.150 ns/op 34 | # Warmup Iteration 3: 67.129 ns/op 35 | # Warmup Iteration 4: 66.831 ns/op 36 | # Warmup Iteration 5: 66.944 ns/op 37 | Iteration 1: 66.745 ns/op 38 | Iteration 2: 66.839 ns/op 39 | Iteration 3: 67.050 ns/op 40 | Iteration 4: 67.059 ns/op 41 | Iteration 5: 66.991 ns/op 42 | Iteration 6: 66.766 ns/op 43 | Iteration 7: 67.008 ns/op 44 | Iteration 8: 67.191 ns/op 45 | Iteration 9: 67.283 ns/op 46 | Iteration 10: 67.141 ns/op 47 | 48 | # Run progress: 13.33% complete, ETA 00:09:49 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 74.044 ns/op 51 | # Warmup Iteration 2: 68.926 ns/op 52 | # Warmup Iteration 3: 68.584 ns/op 53 | # Warmup Iteration 4: 68.341 ns/op 54 | # Warmup Iteration 5: 67.892 ns/op 55 | Iteration 1: 68.266 ns/op 56 | Iteration 2: 67.966 ns/op 57 | Iteration 3: 67.954 ns/op 58 | Iteration 4: 67.972 ns/op 59 | Iteration 5: 68.105 ns/op 60 | Iteration 6: 67.928 ns/op 61 | Iteration 7: 67.955 ns/op 62 | Iteration 8: 68.216 ns/op 63 | Iteration 9: 68.177 ns/op 64 | Iteration 10: 68.883 ns/op 65 | 66 | 67 | Result "mixed_1_plus": 68 | 67.254 ±(99.9%) 0.473 ns/op [Average] 69 | (min, avg, max) = (66.322, 67.254, 68.883), stdev = 0.708 70 | CI (99.9%): [66.781, 67.728] (assumes normal distribution) 71 | 72 | 73 | # JMH 1.12 (released 2030 days ago, please consider updating!) 74 | # VM version: JDK 17, VM 17+35-2724 75 | # VM invoker: /opt/jdk-17/bin/java 76 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:-CompactStrings -XX:+UseParallelGC 77 | # Warmup: 5 iterations, 5 s each 78 | # Measurement: 10 iterations, 2 s each 79 | # Timeout: 10 min per iteration 80 | # Threads: 1 thread, will synchronize iterations 81 | # Benchmark mode: Average time, time/op 82 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_2_sb_sized 83 | 84 | # Run progress: 20.00% complete, ETA 00:09:03 85 | # Fork: 1 of 3 86 | # Warmup Iteration 1: 109.024 ns/op 87 | # Warmup Iteration 2: 100.332 ns/op 88 | # Warmup Iteration 3: 107.201 ns/op 89 | # Warmup Iteration 4: 99.871 ns/op 90 | # Warmup Iteration 5: 99.449 ns/op 91 | Iteration 1: 99.258 ns/op 92 | Iteration 2: 99.316 ns/op 93 | Iteration 3: 99.450 ns/op 94 | Iteration 4: 100.137 ns/op 95 | Iteration 5: 99.424 ns/op 96 | Iteration 6: 99.643 ns/op 97 | Iteration 7: 99.711 ns/op 98 | Iteration 8: 99.276 ns/op 99 | Iteration 9: 99.546 ns/op 100 | Iteration 10: 99.582 ns/op 101 | 102 | # Run progress: 26.67% complete, ETA 00:08:18 103 | # Fork: 2 of 3 104 | # Warmup Iteration 1: 116.378 ns/op 105 | # Warmup Iteration 2: 112.505 ns/op 106 | # Warmup Iteration 3: 100.079 ns/op 107 | # Warmup Iteration 4: 104.672 ns/op 108 | # Warmup Iteration 5: 104.580 ns/op 109 | Iteration 1: 104.354 ns/op 110 | Iteration 2: 104.608 ns/op 111 | Iteration 3: 104.520 ns/op 112 | Iteration 4: 104.664 ns/op 113 | Iteration 5: 104.365 ns/op 114 | Iteration 6: 105.246 ns/op 115 | Iteration 7: 104.820 ns/op 116 | Iteration 8: 104.904 ns/op 117 | Iteration 9: 104.657 ns/op 118 | Iteration 10: 104.662 ns/op 119 | 120 | # Run progress: 33.33% complete, ETA 00:07:33 121 | # Fork: 3 of 3 122 | # Warmup Iteration 1: 106.470 ns/op 123 | # Warmup Iteration 2: 103.912 ns/op 124 | # Warmup Iteration 3: 106.311 ns/op 125 | # Warmup Iteration 4: 97.454 ns/op 126 | # Warmup Iteration 5: 97.498 ns/op 127 | Iteration 1: 97.568 ns/op 128 | Iteration 2: 97.525 ns/op 129 | Iteration 3: 97.354 ns/op 130 | Iteration 4: 97.561 ns/op 131 | Iteration 5: 97.572 ns/op 132 | Iteration 6: 97.819 ns/op 133 | Iteration 7: 97.198 ns/op 134 | Iteration 8: 97.469 ns/op 135 | Iteration 9: 97.690 ns/op 136 | Iteration 10: 97.756 ns/op 137 | 138 | 139 | Result "mixed_2_sb_sized": 140 | 100.589 ±(99.9%) 2.047 ns/op [Average] 141 | (min, avg, max) = (97.198, 100.589, 105.246), stdev = 3.064 142 | CI (99.9%): [98.541, 102.636] (assumes normal distribution) 143 | 144 | 145 | # JMH 1.12 (released 2030 days ago, please consider updating!) 146 | # VM version: JDK 17, VM 17+35-2724 147 | # VM invoker: /opt/jdk-17/bin/java 148 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:-CompactStrings -XX:+UseParallelGC 149 | # Warmup: 5 iterations, 5 s each 150 | # Measurement: 10 iterations, 2 s each 151 | # Timeout: 10 min per iteration 152 | # Threads: 1 thread, will synchronize iterations 153 | # Benchmark mode: Average time, time/op 154 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_3_sb 155 | 156 | # Run progress: 40.00% complete, ETA 00:06:48 157 | # Fork: 1 of 3 158 | # Warmup Iteration 1: 183.729 ns/op 159 | # Warmup Iteration 2: 174.201 ns/op 160 | # Warmup Iteration 3: 165.987 ns/op 161 | # Warmup Iteration 4: 166.282 ns/op 162 | # Warmup Iteration 5: 166.663 ns/op 163 | Iteration 1: 166.299 ns/op 164 | Iteration 2: 166.493 ns/op 165 | Iteration 3: 166.474 ns/op 166 | Iteration 4: 166.369 ns/op 167 | Iteration 5: 166.665 ns/op 168 | Iteration 6: 166.105 ns/op 169 | Iteration 7: 165.298 ns/op 170 | Iteration 8: 166.202 ns/op 171 | Iteration 9: 166.557 ns/op 172 | Iteration 10: 166.518 ns/op 173 | 174 | # Run progress: 46.67% complete, ETA 00:06:02 175 | # Fork: 2 of 3 176 | # Warmup Iteration 1: 152.587 ns/op 177 | # Warmup Iteration 2: 129.856 ns/op 178 | # Warmup Iteration 3: 150.614 ns/op 179 | # Warmup Iteration 4: 139.014 ns/op 180 | # Warmup Iteration 5: 138.223 ns/op 181 | Iteration 1: 138.371 ns/op 182 | Iteration 2: 137.803 ns/op 183 | Iteration 3: 137.891 ns/op 184 | Iteration 4: 137.661 ns/op 185 | Iteration 5: 137.578 ns/op 186 | Iteration 6: 137.356 ns/op 187 | Iteration 7: 138.260 ns/op 188 | Iteration 8: 137.503 ns/op 189 | Iteration 9: 137.772 ns/op 190 | Iteration 10: 137.844 ns/op 191 | 192 | # Run progress: 53.33% complete, ETA 00:05:17 193 | # Fork: 3 of 3 194 | # Warmup Iteration 1: 143.517 ns/op 195 | # Warmup Iteration 2: 141.221 ns/op 196 | # Warmup Iteration 3: 129.032 ns/op 197 | # Warmup Iteration 4: 130.217 ns/op 198 | # Warmup Iteration 5: 130.430 ns/op 199 | Iteration 1: 130.370 ns/op 200 | Iteration 2: 130.101 ns/op 201 | Iteration 3: 130.296 ns/op 202 | Iteration 4: 130.658 ns/op 203 | Iteration 5: 130.968 ns/op 204 | Iteration 6: 130.741 ns/op 205 | Iteration 7: 132.194 ns/op 206 | Iteration 8: 131.323 ns/op 207 | Iteration 9: 132.120 ns/op 208 | Iteration 10: 129.123 ns/op 209 | 210 | 211 | Result "mixed_3_sb": 212 | 144.964 ±(99.9%) 10.442 ns/op [Average] 213 | (min, avg, max) = (129.123, 144.964, 166.665), stdev = 15.629 214 | CI (99.9%): [134.522, 155.405] (assumes normal distribution) 215 | 216 | 217 | # JMH 1.12 (released 2030 days ago, please consider updating!) 218 | # VM version: JDK 17, VM 17+35-2724 219 | # VM invoker: /opt/jdk-17/bin/java 220 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:-CompactStrings -XX:+UseParallelGC 221 | # Warmup: 5 iterations, 5 s each 222 | # Measurement: 10 iterations, 2 s each 223 | # Timeout: 10 min per iteration 224 | # Threads: 1 thread, will synchronize iterations 225 | # Benchmark mode: Average time, time/op 226 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_4_concat 227 | 228 | # Run progress: 60.00% complete, ETA 00:04:32 229 | # Fork: 1 of 3 230 | # Warmup Iteration 1: 211.546 ns/op 231 | # Warmup Iteration 2: 202.145 ns/op 232 | # Warmup Iteration 3: 194.063 ns/op 233 | # Warmup Iteration 4: 195.412 ns/op 234 | # Warmup Iteration 5: 195.444 ns/op 235 | Iteration 1: 194.297 ns/op 236 | Iteration 2: 194.114 ns/op 237 | Iteration 3: 194.919 ns/op 238 | Iteration 4: 195.484 ns/op 239 | Iteration 5: 196.171 ns/op 240 | Iteration 6: 195.609 ns/op 241 | Iteration 7: 193.634 ns/op 242 | Iteration 8: 193.284 ns/op 243 | Iteration 9: 194.590 ns/op 244 | Iteration 10: 195.415 ns/op 245 | 246 | # Run progress: 66.67% complete, ETA 00:03:46 247 | # Fork: 2 of 3 248 | # Warmup Iteration 1: 213.261 ns/op 249 | # Warmup Iteration 2: 195.058 ns/op 250 | # Warmup Iteration 3: 193.843 ns/op 251 | # Warmup Iteration 4: 195.023 ns/op 252 | # Warmup Iteration 5: 195.253 ns/op 253 | Iteration 1: 195.223 ns/op 254 | Iteration 2: 195.688 ns/op 255 | Iteration 3: 196.116 ns/op 256 | Iteration 4: 194.881 ns/op 257 | Iteration 5: 194.621 ns/op 258 | Iteration 6: 195.949 ns/op 259 | Iteration 7: 194.781 ns/op 260 | Iteration 8: 195.138 ns/op 261 | Iteration 9: 195.909 ns/op 262 | Iteration 10: 195.348 ns/op 263 | 264 | # Run progress: 73.33% complete, ETA 00:03:01 265 | # Fork: 3 of 3 266 | # Warmup Iteration 1: 221.690 ns/op 267 | # Warmup Iteration 2: 193.092 ns/op 268 | # Warmup Iteration 3: 193.955 ns/op 269 | # Warmup Iteration 4: 194.523 ns/op 270 | # Warmup Iteration 5: 194.485 ns/op 271 | Iteration 1: 193.728 ns/op 272 | Iteration 2: 194.787 ns/op 273 | Iteration 3: 194.142 ns/op 274 | Iteration 4: 195.992 ns/op 275 | Iteration 5: 197.159 ns/op 276 | Iteration 6: 195.561 ns/op 277 | Iteration 7: 195.704 ns/op 278 | Iteration 8: 195.836 ns/op 279 | Iteration 9: 196.795 ns/op 280 | Iteration 10: 194.201 ns/op 281 | 282 | 283 | Result "mixed_4_concat": 284 | 195.169 ±(99.9%) 0.618 ns/op [Average] 285 | (min, avg, max) = (193.284, 195.169, 197.159), stdev = 0.925 286 | CI (99.9%): [194.551, 195.787] (assumes normal distribution) 287 | 288 | 289 | # JMH 1.12 (released 2030 days ago, please consider updating!) 290 | # VM version: JDK 17, VM 17+35-2724 291 | # VM invoker: /opt/jdk-17/bin/java 292 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:-CompactStrings -XX:+UseParallelGC 293 | # Warmup: 5 iterations, 5 s each 294 | # Measurement: 10 iterations, 2 s each 295 | # Timeout: 10 min per iteration 296 | # Threads: 1 thread, will synchronize iterations 297 | # Benchmark mode: Average time, time/op 298 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_5_format 299 | 300 | # Run progress: 80.00% complete, ETA 00:02:16 301 | # Fork: 1 of 3 302 | # Warmup Iteration 1: 761.067 ns/op 303 | # Warmup Iteration 2: 672.986 ns/op 304 | # Warmup Iteration 3: 675.459 ns/op 305 | # Warmup Iteration 4: 679.856 ns/op 306 | # Warmup Iteration 5: 677.226 ns/op 307 | Iteration 1: 680.048 ns/op 308 | Iteration 2: 679.035 ns/op 309 | Iteration 3: 679.069 ns/op 310 | Iteration 4: 679.512 ns/op 311 | Iteration 5: 678.854 ns/op 312 | Iteration 6: 679.350 ns/op 313 | Iteration 7: 684.003 ns/op 314 | Iteration 8: 679.409 ns/op 315 | Iteration 9: 680.400 ns/op 316 | Iteration 10: 677.665 ns/op 317 | 318 | # Run progress: 86.67% complete, ETA 00:01:30 319 | # Fork: 2 of 3 320 | # Warmup Iteration 1: 760.294 ns/op 321 | # Warmup Iteration 2: 680.489 ns/op 322 | # Warmup Iteration 3: 678.024 ns/op 323 | # Warmup Iteration 4: 689.416 ns/op 324 | # Warmup Iteration 5: 689.210 ns/op 325 | Iteration 1: 690.629 ns/op 326 | Iteration 2: 691.171 ns/op 327 | Iteration 3: 690.581 ns/op 328 | Iteration 4: 691.018 ns/op 329 | Iteration 5: 690.720 ns/op 330 | Iteration 6: 688.316 ns/op 331 | Iteration 7: 689.799 ns/op 332 | Iteration 8: 690.213 ns/op 333 | Iteration 9: 689.982 ns/op 334 | Iteration 10: 691.347 ns/op 335 | 336 | # Run progress: 93.33% complete, ETA 00:00:45 337 | # Fork: 3 of 3 338 | # Warmup Iteration 1: 742.527 ns/op 339 | # Warmup Iteration 2: 660.694 ns/op 340 | # Warmup Iteration 3: 661.635 ns/op 341 | # Warmup Iteration 4: 667.932 ns/op 342 | # Warmup Iteration 5: 667.447 ns/op 343 | Iteration 1: 667.109 ns/op 344 | Iteration 2: 667.212 ns/op 345 | Iteration 3: 664.947 ns/op 346 | Iteration 4: 669.355 ns/op 347 | Iteration 5: 663.137 ns/op 348 | Iteration 6: 666.131 ns/op 349 | Iteration 7: 666.858 ns/op 350 | Iteration 8: 666.076 ns/op 351 | Iteration 9: 666.986 ns/op 352 | Iteration 10: 666.705 ns/op 353 | 354 | 355 | Result "mixed_5_format": 356 | 678.855 ±(99.9%) 6.715 ns/op [Average] 357 | (min, avg, max) = (663.137, 678.855, 691.347), stdev = 10.051 358 | CI (99.9%): [672.140, 685.569] (assumes normal distribution) 359 | 360 | 361 | # Run complete. Total time: 00:11:20 362 | 363 | Benchmark Mode Cnt Score Error Units 364 | StringAppenderBenchmark.mixed_1_plus avgt 30 67.254 ± 0.473 ns/op 365 | StringAppenderBenchmark.mixed_2_sb_sized avgt 30 100.589 ± 2.047 ns/op 366 | StringAppenderBenchmark.mixed_3_sb avgt 30 144.964 ± 10.442 ns/op 367 | StringAppenderBenchmark.mixed_4_concat avgt 30 195.169 ± 0.618 ns/op 368 | StringAppenderBenchmark.mixed_5_format avgt 30 678.855 ± 6.715 ns/op 369 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk11-BC_SB-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 11.0.12, VM 11.0.12+7-LTS 3 | # VM invoker: /opt/zulu11.50.19-ca-jdk11.0.12-linux_x64/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=BC_SB 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 149.422 ns/op 15 | # Warmup Iteration 2: 137.496 ns/op 16 | # Warmup Iteration 3: 129.832 ns/op 17 | # Warmup Iteration 4: 129.399 ns/op 18 | # Warmup Iteration 5: 129.034 ns/op 19 | Iteration 1: 129.487 ns/op 20 | Iteration 2: 128.649 ns/op 21 | Iteration 3: 127.889 ns/op 22 | Iteration 4: 128.067 ns/op 23 | Iteration 5: 128.128 ns/op 24 | Iteration 6: 128.336 ns/op 25 | Iteration 7: 127.914 ns/op 26 | Iteration 8: 127.963 ns/op 27 | Iteration 9: 127.899 ns/op 28 | Iteration 10: 127.882 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 150.538 ns/op 33 | # Warmup Iteration 2: 138.762 ns/op 34 | # Warmup Iteration 3: 136.855 ns/op 35 | # Warmup Iteration 4: 138.184 ns/op 36 | # Warmup Iteration 5: 138.396 ns/op 37 | Iteration 1: 138.243 ns/op 38 | Iteration 2: 137.523 ns/op 39 | Iteration 3: 137.256 ns/op 40 | Iteration 4: 137.629 ns/op 41 | Iteration 5: 138.189 ns/op 42 | Iteration 6: 137.669 ns/op 43 | Iteration 7: 138.582 ns/op 44 | Iteration 8: 137.881 ns/op 45 | Iteration 9: 137.041 ns/op 46 | Iteration 10: 137.711 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 155.128 ns/op 51 | # Warmup Iteration 2: 123.695 ns/op 52 | # Warmup Iteration 3: 122.897 ns/op 53 | # Warmup Iteration 4: 123.066 ns/op 54 | # Warmup Iteration 5: 122.830 ns/op 55 | Iteration 1: 122.752 ns/op 56 | Iteration 2: 122.931 ns/op 57 | Iteration 3: 122.747 ns/op 58 | Iteration 4: 122.981 ns/op 59 | Iteration 5: 123.065 ns/op 60 | Iteration 6: 122.955 ns/op 61 | Iteration 7: 122.867 ns/op 62 | Iteration 8: 123.094 ns/op 63 | Iteration 9: 122.802 ns/op 64 | Iteration 10: 122.962 ns/op 65 | 66 | 67 | Result "plus": 68 | 129.636 ±(99.9%) 4.185 ns/op [Average] 69 | (min, avg, max) = (122.747, 129.636, 138.582), stdev = 6.265 70 | CI (99.9%): [125.451, 133.822] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 129.636 ± 4.185 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk11-BC_SB_SIZED-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 11.0.12, VM 11.0.12+7-LTS 3 | # VM invoker: /opt/zulu11.50.19-ca-jdk11.0.12-linux_x64/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=BC_SB_SIZED 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 103.585 ns/op 15 | # Warmup Iteration 2: 96.272 ns/op 16 | # Warmup Iteration 3: 95.281 ns/op 17 | # Warmup Iteration 4: 95.201 ns/op 18 | # Warmup Iteration 5: 95.290 ns/op 19 | Iteration 1: 95.207 ns/op 20 | Iteration 2: 94.976 ns/op 21 | Iteration 3: 95.073 ns/op 22 | Iteration 4: 95.185 ns/op 23 | Iteration 5: 95.877 ns/op 24 | Iteration 6: 95.562 ns/op 25 | Iteration 7: 96.337 ns/op 26 | Iteration 8: 95.339 ns/op 27 | Iteration 9: 95.381 ns/op 28 | Iteration 10: 95.460 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 113.757 ns/op 33 | # Warmup Iteration 2: 99.257 ns/op 34 | # Warmup Iteration 3: 106.849 ns/op 35 | # Warmup Iteration 4: 106.815 ns/op 36 | # Warmup Iteration 5: 106.811 ns/op 37 | Iteration 1: 107.648 ns/op 38 | Iteration 2: 106.655 ns/op 39 | Iteration 3: 107.134 ns/op 40 | Iteration 4: 106.831 ns/op 41 | Iteration 5: 107.205 ns/op 42 | Iteration 6: 107.043 ns/op 43 | Iteration 7: 106.836 ns/op 44 | Iteration 8: 106.975 ns/op 45 | Iteration 9: 106.896 ns/op 46 | Iteration 10: 107.036 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 102.306 ns/op 51 | # Warmup Iteration 2: 93.777 ns/op 52 | # Warmup Iteration 3: 94.034 ns/op 53 | # Warmup Iteration 4: 94.246 ns/op 54 | # Warmup Iteration 5: 94.242 ns/op 55 | Iteration 1: 94.188 ns/op 56 | Iteration 2: 94.602 ns/op 57 | Iteration 3: 94.349 ns/op 58 | Iteration 4: 94.264 ns/op 59 | Iteration 5: 94.501 ns/op 60 | Iteration 6: 95.346 ns/op 61 | Iteration 7: 95.398 ns/op 62 | Iteration 8: 95.487 ns/op 63 | Iteration 9: 94.847 ns/op 64 | Iteration 10: 94.280 ns/op 65 | 66 | 67 | Result "plus": 68 | 99.064 ±(99.9%) 3.840 ns/op [Average] 69 | (min, avg, max) = (94.188, 99.064, 107.648), stdev = 5.747 70 | CI (99.9%): [95.224, 102.904] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 99.064 ± 3.840 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk11-BC_SB_SIZED_EXACT-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 11.0.12, VM 11.0.12+7-LTS 3 | # VM invoker: /opt/zulu11.50.19-ca-jdk11.0.12-linux_x64/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 100.888 ns/op 15 | # Warmup Iteration 2: 76.330 ns/op 16 | # Warmup Iteration 3: 77.280 ns/op 17 | # Warmup Iteration 4: 77.098 ns/op 18 | # Warmup Iteration 5: 77.611 ns/op 19 | Iteration 1: 77.603 ns/op 20 | Iteration 2: 78.180 ns/op 21 | Iteration 3: 76.793 ns/op 22 | Iteration 4: 77.423 ns/op 23 | Iteration 5: 76.770 ns/op 24 | Iteration 6: 77.260 ns/op 25 | Iteration 7: 78.163 ns/op 26 | Iteration 8: 77.541 ns/op 27 | Iteration 9: 77.343 ns/op 28 | Iteration 10: 77.517 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 96.316 ns/op 33 | # Warmup Iteration 2: 74.854 ns/op 34 | # Warmup Iteration 3: 93.417 ns/op 35 | # Warmup Iteration 4: 93.628 ns/op 36 | # Warmup Iteration 5: 93.371 ns/op 37 | Iteration 1: 93.765 ns/op 38 | Iteration 2: 93.892 ns/op 39 | Iteration 3: 93.402 ns/op 40 | Iteration 4: 94.470 ns/op 41 | Iteration 5: 93.797 ns/op 42 | Iteration 6: 93.580 ns/op 43 | Iteration 7: 93.929 ns/op 44 | Iteration 8: 93.430 ns/op 45 | Iteration 9: 93.836 ns/op 46 | Iteration 10: 93.609 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 79.424 ns/op 51 | # Warmup Iteration 2: 77.017 ns/op 52 | # Warmup Iteration 3: 79.190 ns/op 53 | # Warmup Iteration 4: 77.115 ns/op 54 | # Warmup Iteration 5: 78.028 ns/op 55 | Iteration 1: 77.671 ns/op 56 | Iteration 2: 77.398 ns/op 57 | Iteration 3: 77.814 ns/op 58 | Iteration 4: 77.201 ns/op 59 | Iteration 5: 76.886 ns/op 60 | Iteration 6: 77.119 ns/op 61 | Iteration 7: 77.122 ns/op 62 | Iteration 8: 77.218 ns/op 63 | Iteration 9: 77.561 ns/op 64 | Iteration 10: 77.489 ns/op 65 | 66 | 67 | Result "plus": 68 | 82.859 ±(99.9%) 5.248 ns/op [Average] 69 | (min, avg, max) = (76.770, 82.859, 94.470), stdev = 7.856 70 | CI (99.9%): [77.611, 88.108] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 82.859 ± 5.248 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk11-MH_INLINE_SIZED_EXACT-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 11.0.12, VM 11.0.12+7-LTS 3 | # VM invoker: /opt/zulu11.50.19-ca-jdk11.0.12-linux_x64/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 61.018 ns/op 15 | # Warmup Iteration 2: 55.113 ns/op 16 | # Warmup Iteration 3: 54.749 ns/op 17 | # Warmup Iteration 4: 54.996 ns/op 18 | # Warmup Iteration 5: 54.816 ns/op 19 | Iteration 1: 54.860 ns/op 20 | Iteration 2: 54.776 ns/op 21 | Iteration 3: 54.827 ns/op 22 | Iteration 4: 54.909 ns/op 23 | Iteration 5: 54.968 ns/op 24 | Iteration 6: 55.089 ns/op 25 | Iteration 7: 54.702 ns/op 26 | Iteration 8: 54.626 ns/op 27 | Iteration 9: 54.870 ns/op 28 | Iteration 10: 55.059 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 58.259 ns/op 33 | # Warmup Iteration 2: 55.455 ns/op 34 | # Warmup Iteration 3: 55.051 ns/op 35 | # Warmup Iteration 4: 55.284 ns/op 36 | # Warmup Iteration 5: 54.990 ns/op 37 | Iteration 1: 54.915 ns/op 38 | Iteration 2: 55.045 ns/op 39 | Iteration 3: 54.988 ns/op 40 | Iteration 4: 55.069 ns/op 41 | Iteration 5: 55.327 ns/op 42 | Iteration 6: 55.101 ns/op 43 | Iteration 7: 54.650 ns/op 44 | Iteration 8: 54.878 ns/op 45 | Iteration 9: 55.000 ns/op 46 | Iteration 10: 55.108 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 58.509 ns/op 51 | # Warmup Iteration 2: 55.278 ns/op 52 | # Warmup Iteration 3: 54.834 ns/op 53 | # Warmup Iteration 4: 55.207 ns/op 54 | # Warmup Iteration 5: 54.879 ns/op 55 | Iteration 1: 54.833 ns/op 56 | Iteration 2: 55.083 ns/op 57 | Iteration 3: 54.888 ns/op 58 | Iteration 4: 55.189 ns/op 59 | Iteration 5: 54.780 ns/op 60 | Iteration 6: 55.022 ns/op 61 | Iteration 7: 54.818 ns/op 62 | Iteration 8: 54.923 ns/op 63 | Iteration 9: 54.757 ns/op 64 | Iteration 10: 54.649 ns/op 65 | 66 | 67 | Result "plus": 68 | 54.924 ±(99.9%) 0.113 ns/op [Average] 69 | (min, avg, max) = (54.626, 54.924, 55.327), stdev = 0.169 70 | CI (99.9%): [54.811, 55.036] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 54.924 ± 0.113 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk11-MH_SB_SIZED-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 11.0.12, VM 11.0.12+7-LTS 3 | # VM invoker: /opt/zulu11.50.19-ca-jdk11.0.12-linux_x64/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=MH_SB_SIZED 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 120.176 ns/op 15 | # Warmup Iteration 2: 114.354 ns/op 16 | # Warmup Iteration 3: 112.627 ns/op 17 | # Warmup Iteration 4: 113.140 ns/op 18 | # Warmup Iteration 5: 113.296 ns/op 19 | Iteration 1: 112.473 ns/op 20 | Iteration 2: 112.454 ns/op 21 | Iteration 3: 113.109 ns/op 22 | Iteration 4: 112.082 ns/op 23 | Iteration 5: 112.370 ns/op 24 | Iteration 6: 113.195 ns/op 25 | Iteration 7: 112.276 ns/op 26 | Iteration 8: 112.028 ns/op 27 | Iteration 9: 112.124 ns/op 28 | Iteration 10: 112.308 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 105.858 ns/op 33 | # Warmup Iteration 2: 97.865 ns/op 34 | # Warmup Iteration 3: 98.319 ns/op 35 | # Warmup Iteration 4: 99.460 ns/op 36 | # Warmup Iteration 5: 99.636 ns/op 37 | Iteration 1: 99.502 ns/op 38 | Iteration 2: 98.839 ns/op 39 | Iteration 3: 100.388 ns/op 40 | Iteration 4: 99.643 ns/op 41 | Iteration 5: 100.681 ns/op 42 | Iteration 6: 100.181 ns/op 43 | Iteration 7: 100.410 ns/op 44 | Iteration 8: 100.602 ns/op 45 | Iteration 9: 99.586 ns/op 46 | Iteration 10: 99.619 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 105.803 ns/op 51 | # Warmup Iteration 2: 97.027 ns/op 52 | # Warmup Iteration 3: 95.739 ns/op 53 | # Warmup Iteration 4: 95.874 ns/op 54 | # Warmup Iteration 5: 96.117 ns/op 55 | Iteration 1: 96.161 ns/op 56 | Iteration 2: 95.659 ns/op 57 | Iteration 3: 95.860 ns/op 58 | Iteration 4: 95.618 ns/op 59 | Iteration 5: 95.518 ns/op 60 | Iteration 6: 95.467 ns/op 61 | Iteration 7: 95.510 ns/op 62 | Iteration 8: 95.360 ns/op 63 | Iteration 9: 96.244 ns/op 64 | Iteration 10: 95.909 ns/op 65 | 66 | 67 | Result "plus": 68 | 102.706 ±(99.9%) 4.831 ns/op [Average] 69 | (min, avg, max) = (95.360, 102.706, 113.195), stdev = 7.231 70 | CI (99.9%): [97.875, 107.537] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 102.706 ± 4.831 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk11-MH_SB_SIZED_EXACT-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 11.0.12, VM 11.0.12+7-LTS 3 | # VM invoker: /opt/zulu11.50.19-ca-jdk11.0.12-linux_x64/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 150.987 ns/op 15 | # Warmup Iteration 2: 123.684 ns/op 16 | # Warmup Iteration 3: 153.347 ns/op 17 | # Warmup Iteration 4: 152.616 ns/op 18 | # Warmup Iteration 5: 152.375 ns/op 19 | Iteration 1: 152.017 ns/op 20 | Iteration 2: 152.135 ns/op 21 | Iteration 3: 151.905 ns/op 22 | Iteration 4: 152.581 ns/op 23 | Iteration 5: 152.290 ns/op 24 | Iteration 6: 151.371 ns/op 25 | Iteration 7: 153.304 ns/op 26 | Iteration 8: 152.630 ns/op 27 | Iteration 9: 152.081 ns/op 28 | Iteration 10: 152.510 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 124.539 ns/op 33 | # Warmup Iteration 2: 114.190 ns/op 34 | # Warmup Iteration 3: 130.801 ns/op 35 | # Warmup Iteration 4: 131.302 ns/op 36 | # Warmup Iteration 5: 131.879 ns/op 37 | Iteration 1: 132.818 ns/op 38 | Iteration 2: 131.425 ns/op 39 | Iteration 3: 131.354 ns/op 40 | Iteration 4: 131.249 ns/op 41 | Iteration 5: 131.907 ns/op 42 | Iteration 6: 131.564 ns/op 43 | Iteration 7: 132.079 ns/op 44 | Iteration 8: 130.851 ns/op 45 | Iteration 9: 130.702 ns/op 46 | Iteration 10: 131.031 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 152.043 ns/op 51 | # Warmup Iteration 2: 142.046 ns/op 52 | # Warmup Iteration 3: 145.690 ns/op 53 | # Warmup Iteration 4: 146.503 ns/op 54 | # Warmup Iteration 5: 146.113 ns/op 55 | Iteration 1: 145.304 ns/op 56 | Iteration 2: 145.982 ns/op 57 | Iteration 3: 145.285 ns/op 58 | Iteration 4: 146.601 ns/op 59 | Iteration 5: 146.365 ns/op 60 | Iteration 6: 145.902 ns/op 61 | Iteration 7: 146.078 ns/op 62 | Iteration 8: 146.403 ns/op 63 | Iteration 9: 146.894 ns/op 64 | Iteration 10: 145.632 ns/op 65 | 66 | 67 | Result "plus": 68 | 143.275 ±(99.9%) 5.929 ns/op [Average] 69 | (min, avg, max) = (130.702, 143.275, 153.304), stdev = 8.874 70 | CI (99.9%): [137.346, 149.204] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 143.275 ± 5.929 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk17-BC_SB-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 17, VM 17+35-2724 3 | # VM invoker: /opt/jdk-17/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=BC_SB 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 75.120 ns/op 15 | # Warmup Iteration 2: 65.064 ns/op 16 | # Warmup Iteration 3: 70.392 ns/op 17 | # Warmup Iteration 4: 70.804 ns/op 18 | # Warmup Iteration 5: 70.672 ns/op 19 | Iteration 1: 70.984 ns/op 20 | Iteration 2: 70.605 ns/op 21 | Iteration 3: 70.693 ns/op 22 | Iteration 4: 70.648 ns/op 23 | Iteration 5: 70.791 ns/op 24 | Iteration 6: 70.858 ns/op 25 | Iteration 7: 70.660 ns/op 26 | Iteration 8: 70.670 ns/op 27 | Iteration 9: 70.643 ns/op 28 | Iteration 10: 70.629 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 59.151 ns/op 33 | # Warmup Iteration 2: 56.917 ns/op 34 | # Warmup Iteration 3: 56.688 ns/op 35 | # Warmup Iteration 4: 56.882 ns/op 36 | # Warmup Iteration 5: 56.820 ns/op 37 | Iteration 1: 56.959 ns/op 38 | Iteration 2: 57.320 ns/op 39 | Iteration 3: 56.894 ns/op 40 | Iteration 4: 56.649 ns/op 41 | Iteration 5: 56.997 ns/op 42 | Iteration 6: 56.592 ns/op 43 | Iteration 7: 57.163 ns/op 44 | Iteration 8: 56.690 ns/op 45 | Iteration 9: 56.946 ns/op 46 | Iteration 10: 56.651 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 63.311 ns/op 51 | # Warmup Iteration 2: 60.325 ns/op 52 | # Warmup Iteration 3: 60.301 ns/op 53 | # Warmup Iteration 4: 72.376 ns/op 54 | # Warmup Iteration 5: 72.169 ns/op 55 | Iteration 1: 72.014 ns/op 56 | Iteration 2: 72.541 ns/op 57 | Iteration 3: 72.387 ns/op 58 | Iteration 4: 72.561 ns/op 59 | Iteration 5: 72.480 ns/op 60 | Iteration 6: 72.409 ns/op 61 | Iteration 7: 72.343 ns/op 62 | Iteration 8: 72.054 ns/op 63 | Iteration 9: 71.990 ns/op 64 | Iteration 10: 72.513 ns/op 65 | 66 | 67 | Result "plus": 68 | 66.644 ±(99.9%) 4.712 ns/op [Average] 69 | (min, avg, max) = (56.592, 66.644, 72.561), stdev = 7.053 70 | CI (99.9%): [61.932, 71.356] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 66.644 ± 4.712 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk17-BC_SB_SIZED-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 17, VM 17+35-2724 3 | # VM invoker: /opt/jdk-17/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=BC_SB_SIZED 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 59.399 ns/op 15 | # Warmup Iteration 2: 57.282 ns/op 16 | # Warmup Iteration 3: 56.751 ns/op 17 | # Warmup Iteration 4: 57.007 ns/op 18 | # Warmup Iteration 5: 57.108 ns/op 19 | Iteration 1: 57.141 ns/op 20 | Iteration 2: 57.192 ns/op 21 | Iteration 3: 57.258 ns/op 22 | Iteration 4: 56.986 ns/op 23 | Iteration 5: 56.909 ns/op 24 | Iteration 6: 57.106 ns/op 25 | Iteration 7: 57.094 ns/op 26 | Iteration 8: 57.106 ns/op 27 | Iteration 9: 57.141 ns/op 28 | Iteration 10: 57.147 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 63.591 ns/op 33 | # Warmup Iteration 2: 60.439 ns/op 34 | # Warmup Iteration 3: 60.458 ns/op 35 | # Warmup Iteration 4: 61.273 ns/op 36 | # Warmup Iteration 5: 61.431 ns/op 37 | Iteration 1: 61.332 ns/op 38 | Iteration 2: 61.030 ns/op 39 | Iteration 3: 61.200 ns/op 40 | Iteration 4: 61.054 ns/op 41 | Iteration 5: 61.382 ns/op 42 | Iteration 6: 61.516 ns/op 43 | Iteration 7: 61.274 ns/op 44 | Iteration 8: 61.104 ns/op 45 | Iteration 9: 60.962 ns/op 46 | Iteration 10: 61.305 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 59.580 ns/op 51 | # Warmup Iteration 2: 56.847 ns/op 52 | # Warmup Iteration 3: 57.220 ns/op 53 | # Warmup Iteration 4: 63.201 ns/op 54 | # Warmup Iteration 5: 63.423 ns/op 55 | Iteration 1: 63.176 ns/op 56 | Iteration 2: 63.344 ns/op 57 | Iteration 3: 62.825 ns/op 58 | Iteration 4: 63.361 ns/op 59 | Iteration 5: 63.302 ns/op 60 | Iteration 6: 62.859 ns/op 61 | Iteration 7: 63.377 ns/op 62 | Iteration 8: 63.163 ns/op 63 | Iteration 9: 63.341 ns/op 64 | Iteration 10: 63.234 ns/op 65 | 66 | 67 | Result "plus": 68 | 60.507 ±(99.9%) 1.727 ns/op [Average] 69 | (min, avg, max) = (56.909, 60.507, 63.377), stdev = 2.585 70 | CI (99.9%): [58.781, 62.234] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 60.507 ± 1.727 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk17-BC_SB_SIZED_EXACT-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 17, VM 17+35-2724 3 | # VM invoker: /opt/jdk-17/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 63.209 ns/op 15 | # Warmup Iteration 2: 59.952 ns/op 16 | # Warmup Iteration 3: 79.980 ns/op 17 | # Warmup Iteration 4: 61.291 ns/op 18 | # Warmup Iteration 5: 61.054 ns/op 19 | Iteration 1: 61.081 ns/op 20 | Iteration 2: 61.255 ns/op 21 | Iteration 3: 60.870 ns/op 22 | Iteration 4: 60.902 ns/op 23 | Iteration 5: 61.147 ns/op 24 | Iteration 6: 61.071 ns/op 25 | Iteration 7: 61.046 ns/op 26 | Iteration 8: 61.219 ns/op 27 | Iteration 9: 61.202 ns/op 28 | Iteration 10: 61.029 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 60.591 ns/op 33 | # Warmup Iteration 2: 56.726 ns/op 34 | # Warmup Iteration 3: 57.118 ns/op 35 | # Warmup Iteration 4: 56.509 ns/op 36 | # Warmup Iteration 5: 56.805 ns/op 37 | Iteration 1: 56.615 ns/op 38 | Iteration 2: 56.874 ns/op 39 | Iteration 3: 57.712 ns/op 40 | Iteration 4: 56.980 ns/op 41 | Iteration 5: 57.111 ns/op 42 | Iteration 6: 56.962 ns/op 43 | Iteration 7: 57.019 ns/op 44 | Iteration 8: 57.575 ns/op 45 | Iteration 9: 57.373 ns/op 46 | Iteration 10: 57.287 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 60.445 ns/op 51 | # Warmup Iteration 2: 56.531 ns/op 52 | # Warmup Iteration 3: 57.130 ns/op 53 | # Warmup Iteration 4: 56.925 ns/op 54 | # Warmup Iteration 5: 57.216 ns/op 55 | Iteration 1: 57.214 ns/op 56 | Iteration 2: 57.206 ns/op 57 | Iteration 3: 57.146 ns/op 58 | Iteration 4: 57.268 ns/op 59 | Iteration 5: 57.281 ns/op 60 | Iteration 6: 57.303 ns/op 61 | Iteration 7: 57.256 ns/op 62 | Iteration 8: 57.242 ns/op 63 | Iteration 9: 57.344 ns/op 64 | Iteration 10: 56.990 ns/op 65 | 66 | 67 | Result "plus": 68 | 58.486 ±(99.9%) 1.255 ns/op [Average] 69 | (min, avg, max) = (56.615, 58.486, 61.255), stdev = 1.879 70 | CI (99.9%): [57.231, 59.741] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 58.486 ± 1.255 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk17-MH_INLINE_SIZED_EXACT-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 17, VM 17+35-2724 3 | # VM invoker: /opt/jdk-17/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 59.362 ns/op 15 | # Warmup Iteration 2: 56.847 ns/op 16 | # Warmup Iteration 3: 57.189 ns/op 17 | # Warmup Iteration 4: 57.995 ns/op 18 | # Warmup Iteration 5: 56.532 ns/op 19 | Iteration 1: 56.687 ns/op 20 | Iteration 2: 56.660 ns/op 21 | Iteration 3: 57.054 ns/op 22 | Iteration 4: 56.756 ns/op 23 | Iteration 5: 56.350 ns/op 24 | Iteration 6: 56.556 ns/op 25 | Iteration 7: 56.539 ns/op 26 | Iteration 8: 56.697 ns/op 27 | Iteration 9: 56.388 ns/op 28 | Iteration 10: 56.579 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 59.495 ns/op 33 | # Warmup Iteration 2: 57.337 ns/op 34 | # Warmup Iteration 3: 57.092 ns/op 35 | # Warmup Iteration 4: 57.137 ns/op 36 | # Warmup Iteration 5: 56.841 ns/op 37 | Iteration 1: 56.867 ns/op 38 | Iteration 2: 56.688 ns/op 39 | Iteration 3: 56.824 ns/op 40 | Iteration 4: 56.807 ns/op 41 | Iteration 5: 56.775 ns/op 42 | Iteration 6: 56.654 ns/op 43 | Iteration 7: 56.767 ns/op 44 | Iteration 8: 56.778 ns/op 45 | Iteration 9: 57.022 ns/op 46 | Iteration 10: 56.816 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 59.362 ns/op 51 | # Warmup Iteration 2: 69.180 ns/op 52 | # Warmup Iteration 3: 67.090 ns/op 53 | # Warmup Iteration 4: 66.863 ns/op 54 | # Warmup Iteration 5: 67.102 ns/op 55 | Iteration 1: 66.944 ns/op 56 | Iteration 2: 67.007 ns/op 57 | Iteration 3: 66.509 ns/op 58 | Iteration 4: 66.853 ns/op 59 | Iteration 5: 66.962 ns/op 60 | Iteration 6: 66.543 ns/op 61 | Iteration 7: 66.565 ns/op 62 | Iteration 8: 66.837 ns/op 63 | Iteration 9: 66.962 ns/op 64 | Iteration 10: 66.315 ns/op 65 | 66 | 67 | Result "plus": 68 | 60.059 ±(99.9%) 3.218 ns/op [Average] 69 | (min, avg, max) = (56.350, 60.059, 67.007), stdev = 4.816 70 | CI (99.9%): [56.841, 63.276] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 60.059 ± 3.218 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk17-MH_SB_SIZED-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 17, VM 17+35-2724 3 | # VM invoker: /opt/jdk-17/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=MH_SB_SIZED 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 60.491 ns/op 15 | # Warmup Iteration 2: 56.852 ns/op 16 | # Warmup Iteration 3: 57.418 ns/op 17 | # Warmup Iteration 4: 57.201 ns/op 18 | # Warmup Iteration 5: 57.104 ns/op 19 | Iteration 1: 57.047 ns/op 20 | Iteration 2: 57.095 ns/op 21 | Iteration 3: 57.082 ns/op 22 | Iteration 4: 57.366 ns/op 23 | Iteration 5: 57.147 ns/op 24 | Iteration 6: 57.112 ns/op 25 | Iteration 7: 57.458 ns/op 26 | Iteration 8: 56.952 ns/op 27 | Iteration 9: 57.102 ns/op 28 | Iteration 10: 57.112 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 59.237 ns/op 33 | # Warmup Iteration 2: 57.473 ns/op 34 | # Warmup Iteration 3: 56.799 ns/op 35 | # Warmup Iteration 4: 57.168 ns/op 36 | # Warmup Iteration 5: 57.262 ns/op 37 | Iteration 1: 57.186 ns/op 38 | Iteration 2: 56.728 ns/op 39 | Iteration 3: 56.384 ns/op 40 | Iteration 4: 56.381 ns/op 41 | Iteration 5: 56.387 ns/op 42 | Iteration 6: 56.465 ns/op 43 | Iteration 7: 56.409 ns/op 44 | Iteration 8: 56.382 ns/op 45 | Iteration 9: 56.364 ns/op 46 | Iteration 10: 56.624 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 61.319 ns/op 51 | # Warmup Iteration 2: 56.921 ns/op 52 | # Warmup Iteration 3: 56.645 ns/op 53 | # Warmup Iteration 4: 57.304 ns/op 54 | # Warmup Iteration 5: 56.967 ns/op 55 | Iteration 1: 56.739 ns/op 56 | Iteration 2: 56.663 ns/op 57 | Iteration 3: 56.598 ns/op 58 | Iteration 4: 56.774 ns/op 59 | Iteration 5: 56.835 ns/op 60 | Iteration 6: 56.772 ns/op 61 | Iteration 7: 56.806 ns/op 62 | Iteration 8: 56.790 ns/op 63 | Iteration 9: 57.325 ns/op 64 | Iteration 10: 57.420 ns/op 65 | 66 | 67 | Result "plus": 68 | 56.850 ±(99.9%) 0.229 ns/op [Average] 69 | (min, avg, max) = (56.364, 56.850, 57.458), stdev = 0.342 70 | CI (99.9%): [56.622, 57.079] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 56.850 ± 0.229 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/plus-algorithms/java-jdk17-MH_SB_SIZED_EXACT-2021-10-22-57-25.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 17, VM 17+35-2724 3 | # VM invoker: /opt/jdk-17/bin/java 4 | # VM options: -Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:02:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 63.557 ns/op 15 | # Warmup Iteration 2: 60.248 ns/op 16 | # Warmup Iteration 3: 61.681 ns/op 17 | # Warmup Iteration 4: 60.558 ns/op 18 | # Warmup Iteration 5: 61.923 ns/op 19 | Iteration 1: 61.921 ns/op 20 | Iteration 2: 62.043 ns/op 21 | Iteration 3: 63.159 ns/op 22 | Iteration 4: 61.831 ns/op 23 | Iteration 5: 62.246 ns/op 24 | Iteration 6: 61.634 ns/op 25 | Iteration 7: 61.916 ns/op 26 | Iteration 8: 61.705 ns/op 27 | Iteration 9: 62.588 ns/op 28 | Iteration 10: 62.738 ns/op 29 | 30 | # Run progress: 33.33% complete, ETA 00:01:30 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 60.192 ns/op 33 | # Warmup Iteration 2: 60.321 ns/op 34 | # Warmup Iteration 3: 58.033 ns/op 35 | # Warmup Iteration 4: 57.534 ns/op 36 | # Warmup Iteration 5: 57.589 ns/op 37 | Iteration 1: 57.528 ns/op 38 | Iteration 2: 57.595 ns/op 39 | Iteration 3: 58.030 ns/op 40 | Iteration 4: 57.538 ns/op 41 | Iteration 5: 57.431 ns/op 42 | Iteration 6: 57.361 ns/op 43 | Iteration 7: 57.556 ns/op 44 | Iteration 8: 57.646 ns/op 45 | Iteration 9: 57.489 ns/op 46 | Iteration 10: 57.663 ns/op 47 | 48 | # Run progress: 66.67% complete, ETA 00:00:45 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 76.952 ns/op 51 | # Warmup Iteration 2: 70.244 ns/op 52 | # Warmup Iteration 3: 73.051 ns/op 53 | # Warmup Iteration 4: 59.984 ns/op 54 | # Warmup Iteration 5: 59.876 ns/op 55 | Iteration 1: 60.087 ns/op 56 | Iteration 2: 60.249 ns/op 57 | Iteration 3: 60.021 ns/op 58 | Iteration 4: 60.052 ns/op 59 | Iteration 5: 59.834 ns/op 60 | Iteration 6: 60.180 ns/op 61 | Iteration 7: 59.630 ns/op 62 | Iteration 8: 59.821 ns/op 63 | Iteration 9: 59.810 ns/op 64 | Iteration 10: 60.239 ns/op 65 | 66 | 67 | Result "plus": 68 | 59.918 ±(99.9%) 1.293 ns/op [Average] 69 | (min, avg, max) = (57.361, 59.918, 63.159), stdev = 1.935 70 | CI (99.9%): [58.625, 61.211] (assumes normal distribution) 71 | 72 | 73 | # Run complete. Total time: 00:02:15 74 | 75 | Benchmark Mode Cnt Score Error Units 76 | StringAppenderBenchmark.plus avgt 30 59.918 ± 1.293 ns/op 77 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/tiered/java-jdk17-+TieredCompilation-2021-10-22-15-54.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 17, VM 17+35-2724 3 | # VM invoker: /opt/jdk-17/bin/java 4 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_1_plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:11:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 65.680 ns/op 15 | # Warmup Iteration 2: 60.478 ns/op 16 | # Warmup Iteration 3: 60.194 ns/op 17 | # Warmup Iteration 4: 60.376 ns/op 18 | # Warmup Iteration 5: 60.336 ns/op 19 | Iteration 1: 60.293 ns/op 20 | Iteration 2: 60.253 ns/op 21 | Iteration 3: 60.326 ns/op 22 | Iteration 4: 60.406 ns/op 23 | Iteration 5: 60.330 ns/op 24 | Iteration 6: 60.393 ns/op 25 | Iteration 7: 60.312 ns/op 26 | Iteration 8: 60.462 ns/op 27 | Iteration 9: 60.487 ns/op 28 | Iteration 10: 60.445 ns/op 29 | 30 | # Run progress: 6.67% complete, ETA 00:10:33 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 62.328 ns/op 33 | # Warmup Iteration 2: 59.857 ns/op 34 | # Warmup Iteration 3: 60.052 ns/op 35 | # Warmup Iteration 4: 59.916 ns/op 36 | # Warmup Iteration 5: 59.887 ns/op 37 | Iteration 1: 59.869 ns/op 38 | Iteration 2: 60.727 ns/op 39 | Iteration 3: 60.408 ns/op 40 | Iteration 4: 60.467 ns/op 41 | Iteration 5: 60.159 ns/op 42 | Iteration 6: 60.064 ns/op 43 | Iteration 7: 60.122 ns/op 44 | Iteration 8: 60.113 ns/op 45 | Iteration 9: 60.063 ns/op 46 | Iteration 10: 60.086 ns/op 47 | 48 | # Run progress: 13.33% complete, ETA 00:09:48 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 69.718 ns/op 51 | # Warmup Iteration 2: 60.057 ns/op 52 | # Warmup Iteration 3: 60.747 ns/op 53 | # Warmup Iteration 4: 60.988 ns/op 54 | # Warmup Iteration 5: 60.957 ns/op 55 | Iteration 1: 61.030 ns/op 56 | Iteration 2: 61.049 ns/op 57 | Iteration 3: 60.916 ns/op 58 | Iteration 4: 60.845 ns/op 59 | Iteration 5: 61.021 ns/op 60 | Iteration 6: 60.889 ns/op 61 | Iteration 7: 60.947 ns/op 62 | Iteration 8: 60.816 ns/op 63 | Iteration 9: 60.874 ns/op 64 | Iteration 10: 60.939 ns/op 65 | 66 | 67 | Result "mixed_1_plus": 68 | 60.504 ±(99.9%) 0.234 ns/op [Average] 69 | (min, avg, max) = (59.869, 60.504, 61.049), stdev = 0.351 70 | CI (99.9%): [60.269, 60.738] (assumes normal distribution) 71 | 72 | 73 | # JMH 1.12 (released 2030 days ago, please consider updating!) 74 | # VM version: JDK 17, VM 17+35-2724 75 | # VM invoker: /opt/jdk-17/bin/java 76 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 77 | # Warmup: 5 iterations, 5 s each 78 | # Measurement: 10 iterations, 2 s each 79 | # Timeout: 10 min per iteration 80 | # Threads: 1 thread, will synchronize iterations 81 | # Benchmark mode: Average time, time/op 82 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_2_sb_sized 83 | 84 | # Run progress: 20.00% complete, ETA 00:09:02 85 | # Fork: 1 of 3 86 | # Warmup Iteration 1: 92.257 ns/op 87 | # Warmup Iteration 2: 81.539 ns/op 88 | # Warmup Iteration 3: 78.150 ns/op 89 | # Warmup Iteration 4: 77.666 ns/op 90 | # Warmup Iteration 5: 77.524 ns/op 91 | Iteration 1: 78.700 ns/op 92 | Iteration 2: 77.847 ns/op 93 | Iteration 3: 78.268 ns/op 94 | Iteration 4: 78.259 ns/op 95 | Iteration 5: 78.123 ns/op 96 | Iteration 6: 77.902 ns/op 97 | Iteration 7: 77.695 ns/op 98 | Iteration 8: 77.908 ns/op 99 | Iteration 9: 77.636 ns/op 100 | Iteration 10: 77.814 ns/op 101 | 102 | # Run progress: 26.67% complete, ETA 00:08:17 103 | # Fork: 2 of 3 104 | # Warmup Iteration 1: 93.406 ns/op 105 | # Warmup Iteration 2: 86.291 ns/op 106 | # Warmup Iteration 3: 76.971 ns/op 107 | # Warmup Iteration 4: 77.729 ns/op 108 | # Warmup Iteration 5: 77.867 ns/op 109 | Iteration 1: 77.889 ns/op 110 | Iteration 2: 77.437 ns/op 111 | Iteration 3: 77.768 ns/op 112 | Iteration 4: 78.245 ns/op 113 | Iteration 5: 78.026 ns/op 114 | Iteration 6: 77.876 ns/op 115 | Iteration 7: 77.763 ns/op 116 | Iteration 8: 77.834 ns/op 117 | Iteration 9: 78.210 ns/op 118 | Iteration 10: 77.910 ns/op 119 | 120 | # Run progress: 33.33% complete, ETA 00:07:32 121 | # Fork: 3 of 3 122 | # Warmup Iteration 1: 97.749 ns/op 123 | # Warmup Iteration 2: 106.298 ns/op 124 | # Warmup Iteration 3: 78.366 ns/op 125 | # Warmup Iteration 4: 78.606 ns/op 126 | # Warmup Iteration 5: 79.355 ns/op 127 | Iteration 1: 79.652 ns/op 128 | Iteration 2: 79.542 ns/op 129 | Iteration 3: 79.129 ns/op 130 | Iteration 4: 78.908 ns/op 131 | Iteration 5: 79.120 ns/op 132 | Iteration 6: 78.866 ns/op 133 | Iteration 7: 79.550 ns/op 134 | Iteration 8: 80.019 ns/op 135 | Iteration 9: 78.654 ns/op 136 | Iteration 10: 78.963 ns/op 137 | 138 | 139 | Result "mixed_2_sb_sized": 140 | 78.384 ±(99.9%) 0.467 ns/op [Average] 141 | (min, avg, max) = (77.437, 78.384, 80.019), stdev = 0.699 142 | CI (99.9%): [77.917, 78.851] (assumes normal distribution) 143 | 144 | 145 | # JMH 1.12 (released 2030 days ago, please consider updating!) 146 | # VM version: JDK 17, VM 17+35-2724 147 | # VM invoker: /opt/jdk-17/bin/java 148 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 149 | # Warmup: 5 iterations, 5 s each 150 | # Measurement: 10 iterations, 2 s each 151 | # Timeout: 10 min per iteration 152 | # Threads: 1 thread, will synchronize iterations 153 | # Benchmark mode: Average time, time/op 154 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_3_sb 155 | 156 | # Run progress: 40.00% complete, ETA 00:06:47 157 | # Fork: 1 of 3 158 | # Warmup Iteration 1: 141.498 ns/op 159 | # Warmup Iteration 2: 124.119 ns/op 160 | # Warmup Iteration 3: 124.773 ns/op 161 | # Warmup Iteration 4: 125.315 ns/op 162 | # Warmup Iteration 5: 125.217 ns/op 163 | Iteration 1: 125.192 ns/op 164 | Iteration 2: 125.183 ns/op 165 | Iteration 3: 125.383 ns/op 166 | Iteration 4: 124.892 ns/op 167 | Iteration 5: 125.831 ns/op 168 | Iteration 6: 124.976 ns/op 169 | Iteration 7: 125.243 ns/op 170 | Iteration 8: 125.446 ns/op 171 | Iteration 9: 125.250 ns/op 172 | Iteration 10: 125.227 ns/op 173 | 174 | # Run progress: 46.67% complete, ETA 00:06:02 175 | # Fork: 2 of 3 176 | # Warmup Iteration 1: 150.820 ns/op 177 | # Warmup Iteration 2: 116.257 ns/op 178 | # Warmup Iteration 3: 150.524 ns/op 179 | # Warmup Iteration 4: 149.076 ns/op 180 | # Warmup Iteration 5: 147.222 ns/op 181 | Iteration 1: 147.091 ns/op 182 | Iteration 2: 147.073 ns/op 183 | Iteration 3: 147.098 ns/op 184 | Iteration 4: 147.709 ns/op 185 | Iteration 5: 147.303 ns/op 186 | Iteration 6: 147.096 ns/op 187 | Iteration 7: 147.570 ns/op 188 | Iteration 8: 148.612 ns/op 189 | Iteration 9: 146.773 ns/op 190 | Iteration 10: 146.223 ns/op 191 | 192 | # Run progress: 53.33% complete, ETA 00:05:16 193 | # Fork: 3 of 3 194 | # Warmup Iteration 1: 136.453 ns/op 195 | # Warmup Iteration 2: 121.890 ns/op 196 | # Warmup Iteration 3: 118.778 ns/op 197 | # Warmup Iteration 4: 119.492 ns/op 198 | # Warmup Iteration 5: 119.714 ns/op 199 | Iteration 1: 119.879 ns/op 200 | Iteration 2: 119.705 ns/op 201 | Iteration 3: 119.637 ns/op 202 | Iteration 4: 119.703 ns/op 203 | Iteration 5: 119.191 ns/op 204 | Iteration 6: 119.776 ns/op 205 | Iteration 7: 119.883 ns/op 206 | Iteration 8: 119.266 ns/op 207 | Iteration 9: 120.001 ns/op 208 | Iteration 10: 120.044 ns/op 209 | 210 | 211 | Result "mixed_3_sb": 212 | 130.742 ±(99.9%) 8.087 ns/op [Average] 213 | (min, avg, max) = (119.191, 130.742, 148.612), stdev = 12.105 214 | CI (99.9%): [122.654, 138.829] (assumes normal distribution) 215 | 216 | 217 | # JMH 1.12 (released 2030 days ago, please consider updating!) 218 | # VM version: JDK 17, VM 17+35-2724 219 | # VM invoker: /opt/jdk-17/bin/java 220 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 221 | # Warmup: 5 iterations, 5 s each 222 | # Measurement: 10 iterations, 2 s each 223 | # Timeout: 10 min per iteration 224 | # Threads: 1 thread, will synchronize iterations 225 | # Benchmark mode: Average time, time/op 226 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_4_concat 227 | 228 | # Run progress: 60.00% complete, ETA 00:04:31 229 | # Fork: 1 of 3 230 | # Warmup Iteration 1: 162.413 ns/op 231 | # Warmup Iteration 2: 139.917 ns/op 232 | # Warmup Iteration 3: 161.036 ns/op 233 | # Warmup Iteration 4: 161.085 ns/op 234 | # Warmup Iteration 5: 161.013 ns/op 235 | Iteration 1: 161.095 ns/op 236 | Iteration 2: 161.033 ns/op 237 | Iteration 3: 161.203 ns/op 238 | Iteration 4: 160.714 ns/op 239 | Iteration 5: 161.973 ns/op 240 | Iteration 6: 162.447 ns/op 241 | Iteration 7: 161.615 ns/op 242 | Iteration 8: 162.112 ns/op 243 | Iteration 9: 161.333 ns/op 244 | Iteration 10: 161.747 ns/op 245 | 246 | # Run progress: 66.67% complete, ETA 00:03:46 247 | # Fork: 2 of 3 248 | # Warmup Iteration 1: 175.167 ns/op 249 | # Warmup Iteration 2: 149.486 ns/op 250 | # Warmup Iteration 3: 204.715 ns/op 251 | # Warmup Iteration 4: 205.463 ns/op 252 | # Warmup Iteration 5: 200.413 ns/op 253 | Iteration 1: 206.255 ns/op 254 | Iteration 2: 205.572 ns/op 255 | Iteration 3: 206.611 ns/op 256 | Iteration 4: 205.678 ns/op 257 | Iteration 5: 205.792 ns/op 258 | Iteration 6: 207.071 ns/op 259 | Iteration 7: 206.865 ns/op 260 | Iteration 8: 206.453 ns/op 261 | Iteration 9: 206.836 ns/op 262 | Iteration 10: 206.878 ns/op 263 | 264 | # Run progress: 73.33% complete, ETA 00:03:01 265 | # Fork: 3 of 3 266 | # Warmup Iteration 1: 171.747 ns/op 267 | # Warmup Iteration 2: 163.056 ns/op 268 | # Warmup Iteration 3: 197.752 ns/op 269 | # Warmup Iteration 4: 198.592 ns/op 270 | # Warmup Iteration 5: 198.512 ns/op 271 | Iteration 1: 198.230 ns/op 272 | Iteration 2: 197.623 ns/op 273 | Iteration 3: 198.495 ns/op 274 | Iteration 4: 198.409 ns/op 275 | Iteration 5: 198.303 ns/op 276 | Iteration 6: 198.530 ns/op 277 | Iteration 7: 198.635 ns/op 278 | Iteration 8: 198.594 ns/op 279 | Iteration 9: 198.446 ns/op 280 | Iteration 10: 198.326 ns/op 281 | 282 | 283 | Result "mixed_4_concat": 284 | 188.763 ±(99.9%) 13.279 ns/op [Average] 285 | (min, avg, max) = (160.714, 188.763, 207.071), stdev = 19.875 286 | CI (99.9%): [175.483, 202.042] (assumes normal distribution) 287 | 288 | 289 | # JMH 1.12 (released 2030 days ago, please consider updating!) 290 | # VM version: JDK 17, VM 17+35-2724 291 | # VM invoker: /opt/jdk-17/bin/java 292 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 293 | # Warmup: 5 iterations, 5 s each 294 | # Measurement: 10 iterations, 2 s each 295 | # Timeout: 10 min per iteration 296 | # Threads: 1 thread, will synchronize iterations 297 | # Benchmark mode: Average time, time/op 298 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_5_format 299 | 300 | # Run progress: 80.00% complete, ETA 00:02:15 301 | # Fork: 1 of 3 302 | # Warmup Iteration 1: 714.078 ns/op 303 | # Warmup Iteration 2: 663.802 ns/op 304 | # Warmup Iteration 3: 664.871 ns/op 305 | # Warmup Iteration 4: 668.153 ns/op 306 | # Warmup Iteration 5: 671.380 ns/op 307 | Iteration 1: 671.735 ns/op 308 | Iteration 2: 671.088 ns/op 309 | Iteration 3: 671.189 ns/op 310 | Iteration 4: 671.004 ns/op 311 | Iteration 5: 671.381 ns/op 312 | Iteration 6: 672.005 ns/op 313 | Iteration 7: 671.670 ns/op 314 | Iteration 8: 671.091 ns/op 315 | Iteration 9: 671.849 ns/op 316 | Iteration 10: 672.574 ns/op 317 | 318 | # Run progress: 86.67% complete, ETA 00:01:30 319 | # Fork: 2 of 3 320 | # Warmup Iteration 1: 731.809 ns/op 321 | # Warmup Iteration 2: 669.373 ns/op 322 | # Warmup Iteration 3: 666.445 ns/op 323 | # Warmup Iteration 4: 668.727 ns/op 324 | # Warmup Iteration 5: 672.815 ns/op 325 | Iteration 1: 672.929 ns/op 326 | Iteration 2: 674.374 ns/op 327 | Iteration 3: 673.324 ns/op 328 | Iteration 4: 673.825 ns/op 329 | Iteration 5: 674.059 ns/op 330 | Iteration 6: 674.542 ns/op 331 | Iteration 7: 673.836 ns/op 332 | Iteration 8: 673.655 ns/op 333 | Iteration 9: 674.161 ns/op 334 | Iteration 10: 675.997 ns/op 335 | 336 | # Run progress: 93.33% complete, ETA 00:00:45 337 | # Fork: 3 of 3 338 | # Warmup Iteration 1: 715.680 ns/op 339 | # Warmup Iteration 2: 652.964 ns/op 340 | # Warmup Iteration 3: 655.692 ns/op 341 | # Warmup Iteration 4: 658.567 ns/op 342 | # Warmup Iteration 5: 661.018 ns/op 343 | Iteration 1: 661.637 ns/op 344 | Iteration 2: 662.265 ns/op 345 | Iteration 3: 667.366 ns/op 346 | Iteration 4: 660.742 ns/op 347 | Iteration 5: 660.993 ns/op 348 | Iteration 6: 662.369 ns/op 349 | Iteration 7: 664.139 ns/op 350 | Iteration 8: 664.852 ns/op 351 | Iteration 9: 662.646 ns/op 352 | Iteration 10: 662.273 ns/op 353 | 354 | 355 | Result "mixed_5_format": 356 | 669.519 ±(99.9%) 3.347 ns/op [Average] 357 | (min, avg, max) = (660.742, 669.519, 675.997), stdev = 5.010 358 | CI (99.9%): [666.172, 672.866] (assumes normal distribution) 359 | 360 | 361 | # Run complete. Total time: 00:11:18 362 | 363 | Benchmark Mode Cnt Score Error Units 364 | StringAppenderBenchmark.mixed_1_plus avgt 30 60.504 ± 0.234 ns/op 365 | StringAppenderBenchmark.mixed_2_sb_sized avgt 30 78.384 ± 0.467 ns/op 366 | StringAppenderBenchmark.mixed_3_sb avgt 30 130.742 ± 8.087 ns/op 367 | StringAppenderBenchmark.mixed_4_concat avgt 30 188.763 ± 13.279 ns/op 368 | StringAppenderBenchmark.mixed_5_format avgt 30 669.519 ± 3.347 ns/op 369 | -------------------------------------------------------------------------------- /results/playground-server-1-6-2/tiered/java-jdk18-+TieredCompilation-2021-10-22-15-54.out: -------------------------------------------------------------------------------- 1 | # JMH 1.12 (released 2030 days ago, please consider updating!) 2 | # VM version: JDK 18-ea, VM 18-ea+19-1178 3 | # VM invoker: /opt/jdk-18/bin/java 4 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 5 | # Warmup: 5 iterations, 5 s each 6 | # Measurement: 10 iterations, 2 s each 7 | # Timeout: 10 min per iteration 8 | # Threads: 1 thread, will synchronize iterations 9 | # Benchmark mode: Average time, time/op 10 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_1_plus 11 | 12 | # Run progress: 0.00% complete, ETA 00:11:15 13 | # Fork: 1 of 3 14 | # Warmup Iteration 1: 64.151 ns/op 15 | # Warmup Iteration 2: 61.056 ns/op 16 | # Warmup Iteration 3: 60.341 ns/op 17 | # Warmup Iteration 4: 61.471 ns/op 18 | # Warmup Iteration 5: 61.404 ns/op 19 | Iteration 1: 61.548 ns/op 20 | Iteration 2: 61.529 ns/op 21 | Iteration 3: 61.465 ns/op 22 | Iteration 4: 61.742 ns/op 23 | Iteration 5: 60.443 ns/op 24 | Iteration 6: 60.497 ns/op 25 | Iteration 7: 60.563 ns/op 26 | Iteration 8: 60.556 ns/op 27 | Iteration 9: 60.533 ns/op 28 | Iteration 10: 60.572 ns/op 29 | 30 | # Run progress: 6.67% complete, ETA 00:10:33 31 | # Fork: 2 of 3 32 | # Warmup Iteration 1: 63.719 ns/op 33 | # Warmup Iteration 2: 60.972 ns/op 34 | # Warmup Iteration 3: 60.334 ns/op 35 | # Warmup Iteration 4: 61.177 ns/op 36 | # Warmup Iteration 5: 61.287 ns/op 37 | Iteration 1: 61.440 ns/op 38 | Iteration 2: 61.061 ns/op 39 | Iteration 3: 61.410 ns/op 40 | Iteration 4: 61.258 ns/op 41 | Iteration 5: 60.111 ns/op 42 | Iteration 6: 60.239 ns/op 43 | Iteration 7: 60.248 ns/op 44 | Iteration 8: 60.454 ns/op 45 | Iteration 9: 60.529 ns/op 46 | Iteration 10: 60.348 ns/op 47 | 48 | # Run progress: 13.33% complete, ETA 00:09:47 49 | # Fork: 3 of 3 50 | # Warmup Iteration 1: 63.987 ns/op 51 | # Warmup Iteration 2: 60.666 ns/op 52 | # Warmup Iteration 3: 60.017 ns/op 53 | # Warmup Iteration 4: 60.766 ns/op 54 | # Warmup Iteration 5: 61.141 ns/op 55 | Iteration 1: 61.615 ns/op 56 | Iteration 2: 61.488 ns/op 57 | Iteration 3: 61.430 ns/op 58 | Iteration 4: 61.266 ns/op 59 | Iteration 5: 60.406 ns/op 60 | Iteration 6: 61.670 ns/op 61 | Iteration 7: 60.490 ns/op 62 | Iteration 8: 60.118 ns/op 63 | Iteration 9: 60.028 ns/op 64 | Iteration 10: 59.986 ns/op 65 | 66 | 67 | Result "mixed_1_plus": 68 | 60.835 ±(99.9%) 0.390 ns/op [Average] 69 | (min, avg, max) = (59.986, 60.835, 61.742), stdev = 0.584 70 | CI (99.9%): [60.445, 61.225] (assumes normal distribution) 71 | 72 | 73 | # JMH 1.12 (released 2030 days ago, please consider updating!) 74 | # VM version: JDK 18-ea, VM 18-ea+19-1178 75 | # VM invoker: /opt/jdk-18/bin/java 76 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 77 | # Warmup: 5 iterations, 5 s each 78 | # Measurement: 10 iterations, 2 s each 79 | # Timeout: 10 min per iteration 80 | # Threads: 1 thread, will synchronize iterations 81 | # Benchmark mode: Average time, time/op 82 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_2_sb_sized 83 | 84 | # Run progress: 20.00% complete, ETA 00:09:02 85 | # Fork: 1 of 3 86 | # Warmup Iteration 1: 87.557 ns/op 87 | # Warmup Iteration 2: 81.024 ns/op 88 | # Warmup Iteration 3: 77.909 ns/op 89 | # Warmup Iteration 4: 81.573 ns/op 90 | # Warmup Iteration 5: 81.604 ns/op 91 | Iteration 1: 81.885 ns/op 92 | Iteration 2: 81.970 ns/op 93 | Iteration 3: 81.983 ns/op 94 | Iteration 4: 82.009 ns/op 95 | Iteration 5: 103.890 ns/op 96 | Iteration 6: 103.688 ns/op 97 | Iteration 7: 104.034 ns/op 98 | Iteration 8: 104.016 ns/op 99 | Iteration 9: 104.112 ns/op 100 | Iteration 10: 103.970 ns/op 101 | 102 | # Run progress: 26.67% complete, ETA 00:08:17 103 | # Fork: 2 of 3 104 | # Warmup Iteration 1: 87.222 ns/op 105 | # Warmup Iteration 2: 80.735 ns/op 106 | # Warmup Iteration 3: 77.576 ns/op 107 | # Warmup Iteration 4: 81.907 ns/op 108 | # Warmup Iteration 5: 81.762 ns/op 109 | Iteration 1: 81.392 ns/op 110 | Iteration 2: 81.376 ns/op 111 | Iteration 3: 81.751 ns/op 112 | Iteration 4: 81.351 ns/op 113 | Iteration 5: 91.038 ns/op 114 | Iteration 6: 90.752 ns/op 115 | Iteration 7: 90.996 ns/op 116 | Iteration 8: 90.885 ns/op 117 | Iteration 9: 90.942 ns/op 118 | Iteration 10: 90.820 ns/op 119 | 120 | # Run progress: 33.33% complete, ETA 00:07:32 121 | # Fork: 3 of 3 122 | # Warmup Iteration 1: 87.216 ns/op 123 | # Warmup Iteration 2: 80.889 ns/op 124 | # Warmup Iteration 3: 77.978 ns/op 125 | # Warmup Iteration 4: 81.355 ns/op 126 | # Warmup Iteration 5: 81.406 ns/op 127 | Iteration 1: 82.378 ns/op 128 | Iteration 2: 81.920 ns/op 129 | Iteration 3: 81.834 ns/op 130 | Iteration 4: 81.549 ns/op 131 | Iteration 5: 79.918 ns/op 132 | Iteration 6: 79.876 ns/op 133 | Iteration 7: 80.436 ns/op 134 | Iteration 8: 80.208 ns/op 135 | Iteration 9: 80.056 ns/op 136 | Iteration 10: 80.731 ns/op 137 | 138 | 139 | Result "mixed_2_sb_sized": 140 | 87.726 ±(99.9%) 6.085 ns/op [Average] 141 | (min, avg, max) = (79.876, 87.726, 104.112), stdev = 9.107 142 | CI (99.9%): [81.641, 93.810] (assumes normal distribution) 143 | 144 | 145 | # JMH 1.12 (released 2030 days ago, please consider updating!) 146 | # VM version: JDK 18-ea, VM 18-ea+19-1178 147 | # VM invoker: /opt/jdk-18/bin/java 148 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 149 | # Warmup: 5 iterations, 5 s each 150 | # Measurement: 10 iterations, 2 s each 151 | # Timeout: 10 min per iteration 152 | # Threads: 1 thread, will synchronize iterations 153 | # Benchmark mode: Average time, time/op 154 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_3_sb 155 | 156 | # Run progress: 40.00% complete, ETA 00:06:47 157 | # Fork: 1 of 3 158 | # Warmup Iteration 1: 132.697 ns/op 159 | # Warmup Iteration 2: 123.065 ns/op 160 | # Warmup Iteration 3: 136.441 ns/op 161 | # Warmup Iteration 4: 124.151 ns/op 162 | # Warmup Iteration 5: 123.862 ns/op 163 | Iteration 1: 124.509 ns/op 164 | Iteration 2: 123.720 ns/op 165 | Iteration 3: 124.010 ns/op 166 | Iteration 4: 124.781 ns/op 167 | Iteration 5: 134.212 ns/op 168 | Iteration 6: 133.554 ns/op 169 | Iteration 7: 133.931 ns/op 170 | Iteration 8: 133.250 ns/op 171 | Iteration 9: 133.732 ns/op 172 | Iteration 10: 133.633 ns/op 173 | 174 | # Run progress: 46.67% complete, ETA 00:06:02 175 | # Fork: 2 of 3 176 | # Warmup Iteration 1: 146.885 ns/op 177 | # Warmup Iteration 2: 135.776 ns/op 178 | # Warmup Iteration 3: 127.150 ns/op 179 | # Warmup Iteration 4: 136.927 ns/op 180 | # Warmup Iteration 5: 136.532 ns/op 181 | Iteration 1: 136.277 ns/op 182 | Iteration 2: 135.876 ns/op 183 | Iteration 3: 136.396 ns/op 184 | Iteration 4: 136.057 ns/op 185 | Iteration 5: 135.419 ns/op 186 | Iteration 6: 135.044 ns/op 187 | Iteration 7: 135.140 ns/op 188 | Iteration 8: 134.759 ns/op 189 | Iteration 9: 135.056 ns/op 190 | Iteration 10: 134.905 ns/op 191 | 192 | # Run progress: 53.33% complete, ETA 00:05:16 193 | # Fork: 3 of 3 194 | # Warmup Iteration 1: 128.065 ns/op 195 | # Warmup Iteration 2: 118.158 ns/op 196 | # Warmup Iteration 3: 126.829 ns/op 197 | # Warmup Iteration 4: 119.867 ns/op 198 | # Warmup Iteration 5: 119.358 ns/op 199 | Iteration 1: 119.899 ns/op 200 | Iteration 2: 119.858 ns/op 201 | Iteration 3: 119.749 ns/op 202 | Iteration 4: 119.233 ns/op 203 | Iteration 5: 148.189 ns/op 204 | Iteration 6: 147.827 ns/op 205 | Iteration 7: 145.290 ns/op 206 | Iteration 8: 144.348 ns/op 207 | Iteration 9: 144.389 ns/op 208 | Iteration 10: 145.136 ns/op 209 | 210 | 211 | Result "mixed_3_sb": 212 | 133.606 ±(99.9%) 5.660 ns/op [Average] 213 | (min, avg, max) = (119.233, 133.606, 148.189), stdev = 8.472 214 | CI (99.9%): [127.946, 139.266] (assumes normal distribution) 215 | 216 | 217 | # JMH 1.12 (released 2030 days ago, please consider updating!) 218 | # VM version: JDK 18-ea, VM 18-ea+19-1178 219 | # VM invoker: /opt/jdk-18/bin/java 220 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 221 | # Warmup: 5 iterations, 5 s each 222 | # Measurement: 10 iterations, 2 s each 223 | # Timeout: 10 min per iteration 224 | # Threads: 1 thread, will synchronize iterations 225 | # Benchmark mode: Average time, time/op 226 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_4_concat 227 | 228 | # Run progress: 60.00% complete, ETA 00:04:31 229 | # Fork: 1 of 3 230 | # Warmup Iteration 1: 179.326 ns/op 231 | # Warmup Iteration 2: 159.761 ns/op 232 | # Warmup Iteration 3: 208.048 ns/op 233 | # Warmup Iteration 4: 161.820 ns/op 234 | # Warmup Iteration 5: 161.378 ns/op 235 | Iteration 1: 162.361 ns/op 236 | Iteration 2: 162.283 ns/op 237 | Iteration 3: 159.690 ns/op 238 | Iteration 4: 161.012 ns/op 239 | Iteration 5: 208.427 ns/op 240 | Iteration 6: 207.360 ns/op 241 | Iteration 7: 208.141 ns/op 242 | Iteration 8: 208.065 ns/op 243 | Iteration 9: 206.988 ns/op 244 | Iteration 10: 206.046 ns/op 245 | 246 | # Run progress: 66.67% complete, ETA 00:03:46 247 | # Fork: 2 of 3 248 | # Warmup Iteration 1: 170.181 ns/op 249 | # Warmup Iteration 2: 152.869 ns/op 250 | # Warmup Iteration 3: 153.620 ns/op 251 | # Warmup Iteration 4: 153.508 ns/op 252 | # Warmup Iteration 5: 153.847 ns/op 253 | Iteration 1: 154.041 ns/op 254 | Iteration 2: 153.885 ns/op 255 | Iteration 3: 153.849 ns/op 256 | Iteration 4: 154.129 ns/op 257 | Iteration 5: 158.180 ns/op 258 | Iteration 6: 157.604 ns/op 259 | Iteration 7: 157.927 ns/op 260 | Iteration 8: 157.646 ns/op 261 | Iteration 9: 157.291 ns/op 262 | Iteration 10: 158.006 ns/op 263 | 264 | # Run progress: 73.33% complete, ETA 00:03:01 265 | # Fork: 3 of 3 266 | # Warmup Iteration 1: 160.563 ns/op 267 | # Warmup Iteration 2: 144.372 ns/op 268 | # Warmup Iteration 3: 153.797 ns/op 269 | # Warmup Iteration 4: 146.181 ns/op 270 | # Warmup Iteration 5: 145.167 ns/op 271 | Iteration 1: 146.448 ns/op 272 | Iteration 2: 145.974 ns/op 273 | Iteration 3: 146.314 ns/op 274 | Iteration 4: 146.281 ns/op 275 | Iteration 5: 155.155 ns/op 276 | Iteration 6: 153.413 ns/op 277 | Iteration 7: 152.372 ns/op 278 | Iteration 8: 152.732 ns/op 279 | Iteration 9: 153.401 ns/op 280 | Iteration 10: 152.817 ns/op 281 | 282 | 283 | Result "mixed_4_concat": 284 | 165.261 ±(99.9%) 14.643 ns/op [Average] 285 | (min, avg, max) = (145.974, 165.261, 208.427), stdev = 21.917 286 | CI (99.9%): [150.618, 179.904] (assumes normal distribution) 287 | 288 | 289 | # JMH 1.12 (released 2030 days ago, please consider updating!) 290 | # VM version: JDK 18-ea, VM 18-ea+19-1178 291 | # VM invoker: /opt/jdk-18/bin/java 292 | # VM options: -Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC 293 | # Warmup: 5 iterations, 5 s each 294 | # Measurement: 10 iterations, 2 s each 295 | # Timeout: 10 min per iteration 296 | # Threads: 1 thread, will synchronize iterations 297 | # Benchmark mode: Average time, time/op 298 | # Benchmark: eu.javaspecialists.perf.string.StringAppenderBenchmark.mixed_5_format 299 | 300 | # Run progress: 80.00% complete, ETA 00:02:15 301 | # Fork: 1 of 3 302 | # Warmup Iteration 1: 756.594 ns/op 303 | # Warmup Iteration 2: 700.378 ns/op 304 | # Warmup Iteration 3: 699.012 ns/op 305 | # Warmup Iteration 4: 706.058 ns/op 306 | # Warmup Iteration 5: 715.144 ns/op 307 | Iteration 1: 712.979 ns/op 308 | Iteration 2: 711.885 ns/op 309 | Iteration 3: 715.032 ns/op 310 | Iteration 4: 712.803 ns/op 311 | Iteration 5: 719.756 ns/op 312 | Iteration 6: 719.271 ns/op 313 | Iteration 7: 719.060 ns/op 314 | Iteration 8: 718.463 ns/op 315 | Iteration 9: 717.265 ns/op 316 | Iteration 10: 714.497 ns/op 317 | 318 | # Run progress: 86.67% complete, ETA 00:01:30 319 | # Fork: 2 of 3 320 | # Warmup Iteration 1: 722.142 ns/op 321 | # Warmup Iteration 2: 682.600 ns/op 322 | # Warmup Iteration 3: 682.022 ns/op 323 | # Warmup Iteration 4: 687.038 ns/op 324 | # Warmup Iteration 5: 687.913 ns/op 325 | Iteration 1: 688.029 ns/op 326 | Iteration 2: 686.297 ns/op 327 | Iteration 3: 686.982 ns/op 328 | Iteration 4: 686.707 ns/op 329 | Iteration 5: 684.545 ns/op 330 | Iteration 6: 684.917 ns/op 331 | Iteration 7: 685.496 ns/op 332 | Iteration 8: 685.345 ns/op 333 | Iteration 9: 685.907 ns/op 334 | Iteration 10: 685.530 ns/op 335 | 336 | # Run progress: 93.33% complete, ETA 00:00:45 337 | # Fork: 3 of 3 338 | # Warmup Iteration 1: 717.581 ns/op 339 | # Warmup Iteration 2: 673.900 ns/op 340 | # Warmup Iteration 3: 681.474 ns/op 341 | # Warmup Iteration 4: 678.327 ns/op 342 | # Warmup Iteration 5: 678.194 ns/op 343 | Iteration 1: 678.611 ns/op 344 | Iteration 2: 677.814 ns/op 345 | Iteration 3: 678.445 ns/op 346 | Iteration 4: 678.947 ns/op 347 | Iteration 5: 681.421 ns/op 348 | Iteration 6: 680.989 ns/op 349 | Iteration 7: 681.110 ns/op 350 | Iteration 8: 681.106 ns/op 351 | Iteration 9: 680.496 ns/op 352 | Iteration 10: 680.941 ns/op 353 | 354 | 355 | Result "mixed_5_format": 356 | 694.022 ±(99.9%) 10.816 ns/op [Average] 357 | (min, avg, max) = (677.814, 694.022, 719.756), stdev = 16.188 358 | CI (99.9%): [683.206, 704.837] (assumes normal distribution) 359 | 360 | 361 | # Run complete. Total time: 00:11:18 362 | 363 | Benchmark Mode Cnt Score Error Units 364 | StringAppenderBenchmark.mixed_1_plus avgt 30 60.835 ± 0.390 ns/op 365 | StringAppenderBenchmark.mixed_2_sb_sized avgt 30 87.726 ± 6.085 ns/op 366 | StringAppenderBenchmark.mixed_3_sb avgt 30 133.606 ± 5.660 ns/op 367 | StringAppenderBenchmark.mixed_4_concat avgt 30 165.261 ± 14.643 ns/op 368 | StringAppenderBenchmark.mixed_5_format avgt 30 694.022 ± 10.816 ns/op 369 | -------------------------------------------------------------------------------- /runall.sh: -------------------------------------------------------------------------------- 1 | DATE=`date "+%Y-%m-%d-%M-%S"` 2 | 3 | for i in 6 7 8; do 4 | echo $i; 5 | export JAVA_HOME=/opt/jdk-$i 6 | /opt/jdk-$i/bin/java -showversion -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs '-Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC' StringAppenderBenchmark.mixed > java-jdk$i-+TieredCompilation-$DATE.out 7 | #/opt/jdk-$i/bin/java -showversion -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs '-Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC' > java-jdk$i-$DATE.out 8 | done 9 | 10 | for i in 11 17 18 9 10 12 13 14 15; do 11 | echo $i; 12 | export JAVA_HOME=/opt/jdk-$i 13 | /opt/jdk-$i/bin/java -showversion --add-opens java.base/java.io=ALL-UNNAMED -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs '-Xmx8g -XX:+TieredCompilation -XX:+UseParallelGC' StringAppenderBenchmark.mixed > java-jdk$i-+TieredCompilation-$DATE.out 14 | #/opt/jdk-$i/bin/java -showversion --add-opens java.base/java.io=ALL-UNNAMED -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs '-Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC' > java-jdk$i-$DATE.out 15 | done 16 | -------------------------------------------------------------------------------- /runconcat.sh: -------------------------------------------------------------------------------- 1 | DATE=`date "+%Y-%m-%d-%M-%S"` 2 | 3 | for algo in MH_INLINE_SIZED_EXACT BC_SB_SIZED_EXACT MH_SB_SIZED BC_SB_SIZED MH_SB_SIZED_EXACT BC_SB; do 4 | for i in 11 17; do 5 | echo $i; 6 | export JAVA_HOME=/opt/jdk-$i 7 | JVM_ARGS="-Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC -Djava.lang.invoke.stringConcat=$algo" 8 | /opt/jdk-$i/bin/java -showversion --add-opens java.base/java.io=ALL-UNNAMED -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs "${JVM_ARGS}" StringAppenderBenchmark.plus > java-jdk$i-$algo-$DATE.out 9 | /opt/jdk-$i/bin/java -showversion --add-opens java.base/java.io=ALL-UNNAMED -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs "${JVM_ARGS}" -prof gc StringAppenderBenchmark.plus > java-jdk$i-gc-$algo-$DATE.out 10 | done 11 | done 12 | 13 | -------------------------------------------------------------------------------- /rungc.sh: -------------------------------------------------------------------------------- 1 | DATE=`date "+%Y-%m-%d-%M-%S"` 2 | 3 | for i in 6 7 8; do 4 | echo $i; 5 | export JAVA_HOME=/opt/jdk-$i 6 | /opt/jdk-$i/bin/java -showversion -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs '-Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC' -prof gc StringAppender -f 1 -r 1 -w 1 > java-jdk$i-gc-$DATE.out 7 | done 8 | 9 | for i in 11 17; do 10 | echo $i; 11 | export JAVA_HOME=/opt/jdk-$i 12 | /opt/jdk-$i/bin/java -showversion --add-opens java.base/java.io=ALL-UNNAMED -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs '-Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC' -prof gc StringAppender -f 1 -r 1 -w 1 > java-jdk$i-gc-$DATE.out 13 | done 14 | -------------------------------------------------------------------------------- /runmissing.sh: -------------------------------------------------------------------------------- 1 | DATE=`date "+%Y-%m-%d-%M-%S"` 2 | 3 | for i in 18 16 15 14 13 12 10 9 ; do 4 | echo $i; 5 | export JAVA_HOME=/opt/jdk-$i 6 | /opt/jdk-$i/bin/java -showversion --add-opens java.base/java.io=ALL-UNNAMED -jar build/libs/string-performance-benchmarks-jdk-$i.jar -jvmArgs '-Xmx8g -XX:-TieredCompilation -XX:+UseParallelGC' StringAppender > java-jdk$i-$DATE.out 7 | done 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'string-performance' 2 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/AbstractStringAppendBenchmark.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | import eu.javaspecialists.perf.util.*; 4 | import org.openjdk.jmh.annotations.*; 5 | 6 | import java.lang.management.*; 7 | import java.util.*; 8 | import java.util.concurrent.*; 9 | import java.util.stream.*; 10 | 11 | /** 12 | * Testing the various algorithms currently employed in the StringConcatFactory. 13 | * 14 | * @see java.lang.invoke.StringConcatFactory 15 | */ 16 | @Fork(3) 17 | @Warmup(iterations = 5, time = 5) 18 | @Measurement(iterations = 10, time = 2) 19 | @BenchmarkMode(Mode.AverageTime) 20 | @OutputTimeUnit(TimeUnit.NANOSECONDS) 21 | @State(Scope.Benchmark) 22 | public abstract class AbstractStringAppendBenchmark { 23 | private static final int NUMBER_OF_DIFFERENT_VALUES = 1024; 24 | private static final int MASK = NUMBER_OF_DIFFERENT_VALUES - 1; 25 | private final static ThreadMXBean tmb = ManagementFactory.getThreadMXBean(); 26 | private String[] stringValues; 27 | private long[] longValues; 28 | private int nextNumber; 29 | private ByteWatcherSingleThread byteWatcher; 30 | 31 | public long calculateAllocations() { 32 | return byteWatcher.calculateAllocations(); 33 | } 34 | 35 | /** 36 | * Deliberately not thread safe to avoid a bottleneck on synchronization 37 | */ 38 | protected String nextString() { 39 | return stringValues[(nextNumber++) & MASK]; 40 | } 41 | 42 | protected long nextLong() { 43 | return longValues[(nextNumber++) & MASK]; 44 | } 45 | 46 | @Setup 47 | public void setup() { 48 | Random random = new Random(); 49 | longValues = new long[NUMBER_OF_DIFFERENT_VALUES]; 50 | stringValues = new String[longValues.length]; 51 | for (int i = 0; i < longValues.length; i++) { 52 | longValues[i] = random.nextLong() / 2 + (Long.MAX_VALUE / 2); 53 | stringValues[i] = "" + longValues[i]; 54 | } 55 | byteWatcher = new ByteWatcherSingleThread(); 56 | byteWatcher.reset(); 57 | } 58 | 59 | @TearDown 60 | public void tearDown() { 61 | long bytesAllocated = byteWatcher.calculateAllocations(); 62 | System.out.printf(Locale.US, "%n### bytes allocated %,d%n", bytesAllocated); 63 | byteWatcher = null; 64 | } 65 | 66 | 67 | @Benchmark 68 | public String stringAdditionWithPlus() { 69 | String title = nextString(); 70 | long id1 = nextLong(); 71 | String optiontxt1 = nextString(); 72 | long id2 = nextLong(); 73 | String optiontxt2 = nextString(); 74 | return "

" + title + "

" + 75 | ""; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/HashCodeBenchmark.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | import org.openjdk.jmh.annotations.*; 4 | import org.openjdk.jmh.infra.*; 5 | 6 | import java.util.*; 7 | import java.util.concurrent.*; 8 | 9 | @Fork(3) 10 | @Warmup(iterations = 5, time = 5) 11 | @Measurement(iterations = 10, time = 2) 12 | @BenchmarkMode(Mode.AverageTime) 13 | @OutputTimeUnit(TimeUnit.NANOSECONDS) 14 | @State(Scope.Benchmark) 15 | public class HashCodeBenchmark { 16 | private static final char[] lettersInLatinAlphabet = new char[26 * 2]; 17 | static { 18 | for (int i = 0; i < lettersInLatinAlphabet.length / 2; i++) { 19 | lettersInLatinAlphabet[i] = (char) ('a' + i); 20 | lettersInLatinAlphabet[i + 26] = (char) ('A' + i); 21 | } 22 | } 23 | @Param({"100", "1000", "10000"}) 24 | private int length; 25 | 26 | private char[] value; 27 | 28 | @Setup 29 | public void setup() { 30 | Random random = new Random(); 31 | value = new char[length]; 32 | for (int i = 0; i < value.length; i++) { 33 | value[i] = lettersInLatinAlphabet[random.nextInt(lettersInLatinAlphabet.length)]; 34 | } 35 | System.out.println(new String(value)); 36 | } 37 | 38 | @Benchmark 39 | public void testHashCodeJava1(Blackhole bh) { 40 | bh.consume(hashCodeJava1(value, 0, length)); 41 | } 42 | 43 | public int hashCodeJava1(char[] value, int offset, int count) { 44 | int h = 0; 45 | int off = offset; 46 | char val[] = value; 47 | int len = count; 48 | 49 | if (len < 16) { 50 | for (int i = len; i > 0; i--) { 51 | h = (h * 37) + val[off++]; 52 | } 53 | } else { 54 | // only sample some characters 55 | int skip = len / 8; 56 | for (int i = len; i > 0; i -= skip, off += skip) { 57 | h = (h * 39) + val[off]; 58 | } 59 | } 60 | return h; 61 | } 62 | 63 | @Benchmark 64 | public void testHashCodeJava2(Blackhole bh) { 65 | bh.consume(hashCodeJava2(value, 0, length)); 66 | } 67 | 68 | public int hashCodeJava2(char[] value, int offset, int count) { 69 | int h = 0; 70 | int off = offset; 71 | char val[] = value; 72 | int len = count; 73 | 74 | for (int i = 0; i < len; i++) 75 | h = 31 * h + val[off++]; 76 | 77 | return h; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/InternBenchmark.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | import org.openjdk.jmh.annotations.*; 4 | import org.openjdk.jmh.infra.*; 5 | 6 | import java.util.*; 7 | import java.util.concurrent.*; 8 | 9 | @Fork(3) 10 | @Warmup(iterations = 5, time = 5) 11 | @Measurement(iterations = 10, time = 2) 12 | @BenchmarkMode(Mode.AverageTime) 13 | @OutputTimeUnit(TimeUnit.NANOSECONDS) 14 | @State(Scope.Benchmark) 15 | public class InternBenchmark { 16 | @Param({"100", "100000", "10000000"}) 17 | private int limit; 18 | 19 | private int value; 20 | 21 | @Setup 22 | public void setup() { 23 | value = 100; 24 | } 25 | 26 | @Benchmark 27 | public String creatingStrings(Blackhole bh) { 28 | return nextValue(); 29 | } 30 | 31 | @Benchmark 32 | public String interningString() { 33 | return nextValue().intern(); 34 | } 35 | 36 | private final ConcurrentMap cache = 37 | new ConcurrentHashMap(); 38 | 39 | @Benchmark 40 | public String chmString() { 41 | String next = nextValue(); 42 | String putResult = cache.putIfAbsent(next, next); 43 | return putResult == null ? next : putResult; 44 | } 45 | 46 | private String nextValue() { 47 | value++; 48 | if (value > limit) value = 0; 49 | return Integer.toHexString(value); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/NumberToStringBenchmark.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | import org.openjdk.jmh.annotations.*; 4 | 5 | import java.util.concurrent.*; 6 | 7 | @Fork(3) 8 | @Warmup(iterations = 5, time = 5) 9 | @Measurement(iterations = 10, time = 2) 10 | @BenchmarkMode(Mode.AverageTime) 11 | @OutputTimeUnit(TimeUnit.NANOSECONDS) 12 | @State(Scope.Benchmark) 13 | public class NumberToStringBenchmark { 14 | private int intVal = 1640531527; 15 | private long longVal = -8454749669228202880L; 16 | 17 | @Benchmark 18 | public String int_plus() { 19 | return "" + intVal; 20 | } 21 | 22 | @Benchmark 23 | public String int_toString() { 24 | return Integer.toString(intVal); 25 | } 26 | 27 | @Benchmark 28 | public String long_plus() { 29 | return "" + longVal; 30 | } 31 | 32 | @Benchmark 33 | public String long_toString() { 34 | return Long.toString(longVal); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/PlainStringAppendBenchmark.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | import org.openjdk.jmh.annotations.*; 4 | import org.openjdk.jmh.infra.*; 5 | 6 | @Fork(3) 7 | @Warmup(iterations = 5, time = 5) 8 | @Measurement(iterations = 10, time = 2) 9 | public class PlainStringAppendBenchmark extends AbstractStringAppendBenchmark { 10 | @Benchmark 11 | public void withoutAnyStringAppending(Blackhole bh) { 12 | bh.consume(nextString()); 13 | bh.consume(nextString()); 14 | bh.consume(nextLong()); 15 | } 16 | 17 | @Benchmark 18 | public String stringBuilder() { 19 | String title = nextString(); 20 | long id1 = nextLong(); 21 | String optiontxt1 = nextString(); 22 | long id2 = nextLong(); 23 | String optiontxt2 = nextString(); 24 | return new StringBuilder().append("

").append(title).append("

  • ") 25 | .append(id1).append(" ") 26 | .append(optiontxt1).append("
  • ").append(id2).append(" ") 27 | .append(optiontxt2).append("
").toString(); 28 | 29 | } 30 | 31 | @Benchmark 32 | public String stringBuilderSized() { 33 | String title = nextString(); 34 | long id1 = nextLong(); 35 | String optiontxt1 = nextString(); 36 | long id2 = nextLong(); 37 | String optiontxt2 = nextString(); 38 | return new StringBuilder(52 + title.length() + 19 + optiontxt1.length() + 19 + optiontxt2.length()) 39 | .append("

").append(title).append("

  • ") 40 | .append(id1).append(" ") 41 | .append(optiontxt1).append("
  • ").append(id2).append(" ") 42 | .append(optiontxt2).append("
").toString(); 43 | } 44 | 45 | @Benchmark 46 | public String stringBuffer() { 47 | String title = nextString(); 48 | long id1 = nextLong(); 49 | String optiontxt1 = nextString(); 50 | long id2 = nextLong(); 51 | String optiontxt2 = nextString(); 52 | return new StringBuffer().append("

").append(title).append("

  • ") 53 | .append(id1).append(" ") 54 | .append(optiontxt1).append("
  • ").append(id2).append(" ") 55 | .append(optiontxt2).append("
").toString(); 56 | } 57 | 58 | @Benchmark 59 | public String stringBufferSized() { 60 | String title = nextString(); 61 | long id1 = nextLong(); 62 | String optiontxt1 = nextString(); 63 | long id2 = nextLong(); 64 | String optiontxt2 = nextString(); 65 | return new StringBuffer(52 + title.length() + 19 + optiontxt1.length() + 19 + optiontxt2.length()) 66 | .append("

").append(title).append("

  • ") 67 | .append(id1).append(" ") 68 | .append(optiontxt1).append("
  • ").append(id2).append(" ") 69 | .append(optiontxt2).append("
").toString(); 70 | } 71 | 72 | @Benchmark 73 | public String stringFormat() { 74 | String title = nextString(); 75 | long id1 = nextLong(); 76 | String optiontxt1 = nextString(); 77 | long id2 = nextLong(); 78 | String optiontxt2 = nextString(); 79 | return String.format("

%s

  • %d %s
  • %d %s
", title, id1, optiontxt1, id2, optiontxt2); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/StringAppenderAppendBenchmark.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | import org.openjdk.jmh.annotations.Benchmark; 4 | import org.openjdk.jmh.annotations.BenchmarkMode; 5 | import org.openjdk.jmh.annotations.Mode; 6 | import org.openjdk.jmh.annotations.OperationsPerInvocation; 7 | import org.openjdk.jmh.annotations.OutputTimeUnit; 8 | import org.openjdk.jmh.annotations.Scope; 9 | import org.openjdk.jmh.annotations.State; 10 | 11 | import java.util.concurrent.TimeUnit; 12 | 13 | @State(Scope.Benchmark) 14 | @BenchmarkMode(Mode.AverageTime) 15 | @OutputTimeUnit(TimeUnit.NANOSECONDS) 16 | public class StringAppenderAppendBenchmark { 17 | private static final char[] chars = 18 | "thequickbrownfoxjumpsoverlazydog".toCharArray(); 19 | private static final String[] strings = 20 | new String(chars).chars() 21 | .mapToObj(c -> "" + (char) c) 22 | .toArray(String[]::new); 23 | private static final int MASK = chars.length - 1; 24 | 25 | @Benchmark 26 | @OperationsPerInvocation(1024) 27 | public StringBuilder testAppendChar() { 28 | StringBuilder sb = new StringBuilder(); 29 | for (int i = 0; i < 1024; i++) { 30 | sb.append(chars[i & MASK]); 31 | } 32 | return sb; 33 | } 34 | 35 | @Benchmark 36 | @OperationsPerInvocation(1024) 37 | public StringBuilder testAppendString() { 38 | StringBuilder sb = new StringBuilder(); 39 | for (int i = 0; i < 1024; i++) { 40 | sb.append(strings[i & MASK]); 41 | } 42 | return sb; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/StringAppenderBenchmark.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | import org.openjdk.jmh.annotations.*; 4 | 5 | import java.text.*; 6 | import java.util.*; 7 | import java.util.concurrent.*; 8 | 9 | import static eu.javaspecialists.perf.string.StringAppenderConstants.*; 10 | 11 | @Fork(3) 12 | @Warmup(iterations = 5, time = 5) 13 | @Measurement(iterations = 10, time = 2) 14 | @BenchmarkMode(Mode.AverageTime) 15 | @OutputTimeUnit(TimeUnit.NANOSECONDS) 16 | @State(Scope.Benchmark) 17 | public class StringAppenderBenchmark { 18 | private String title = STRING_BENCHMARKS; 19 | private long id1 = ID1; 20 | private long id2 = ID2; 21 | private String optiontxt1 = PLUS_VS_CONCAT; 22 | private String optiontxt2 = STRING_BUILDER; 23 | private MessageFormat messageFormat; 24 | 25 | @Setup 26 | public void setup() { 27 | messageFormat = new MessageFormat("

{0}

  • {1} {2}
  • {3} {4}
", Locale.US); 28 | NumberFormat integerInstance = NumberFormat.getIntegerInstance(Locale.US); 29 | integerInstance.setGroupingUsed(false); 30 | messageFormat.setFormat(1, integerInstance); 31 | messageFormat.setFormat(3, integerInstance); 32 | } 33 | 34 | @Benchmark 35 | public String mixed_1_plus() { 36 | // 4 16 5 12 5 10 37 | return "

" + title + "

  • " + id1 + " " + optiontxt1 + "
  • " + id2 + " " + optiontxt2 + "
"; 38 | } 39 | 40 | @Benchmark 41 | public String mixed_2_sb_sized() { 42 | return new StringBuilder(52 + title.length() + 10 + optiontxt1.length() + 6 + optiontxt2.length()) 43 | .append("

").append(title).append("

  • ").append(id1).append(" ").append(optiontxt1) 44 | .append("
  • ").append(id2).append(" ").append(optiontxt2).append("
").toString(); 45 | } 46 | 47 | @Benchmark 48 | public String mixed_3_sb() { 49 | return new StringBuilder() 50 | .append("

").append(title).append("

  • ").append(id1).append(" ").append(optiontxt1) 51 | .append("
  • ").append(id2).append(" ").append(optiontxt2).append("
").toString(); 52 | } 53 | 54 | @Benchmark 55 | public String mixed_4_concat() { 56 | return "

".concat(title).concat("

  • ").concat(Long.toString(id1)).concat(" ").concat(optiontxt1) 57 | .concat("
  • ").concat(Long.toString(id2)).concat(" ").concat(optiontxt2).concat("
"); 58 | } 59 | 60 | @Benchmark 61 | public String mixed_5_format() { 62 | return String.format("

%s

  • %d %s
  • %d %s
", title, id1, optiontxt1, id2, optiontxt2); 63 | } 64 | 65 | // Test only works Java 15+ 66 | // private static final String FORMAT = 67 | // "

%s

  • %d %s
  • %d %s
"; 68 | // @Benchmark 69 | // public String formatted() { 70 | // return FORMAT.formatted(title, id1, optiontxt1, id2, optiontxt2); 71 | // } 72 | 73 | // @Benchmark 74 | public String message_format_cached_instance() { 75 | return messageFormat.format(new Object[]{title, id1, optiontxt1, id2, optiontxt2}); 76 | } 77 | 78 | //@Benchmark 79 | public String message_format() { 80 | return MessageFormat.format("

{0}

  • {1} {2}
  • {3} {4}
", new Object[]{title, id1, optiontxt1, id2, optiontxt2}); 81 | } 82 | 83 | @Benchmark 84 | public String strings_1_appendBasic() { 85 | String question = title, answer1 = optiontxt1, answer2 = optiontxt2; 86 | return "

" + question + "

  1. " + answer1 + 87 | "
  2. " + answer2 + "
"; 88 | } 89 | 90 | @Benchmark 91 | public String strings_2_appendStringBuilder() { 92 | String question = title, answer1 = optiontxt1, answer2 = optiontxt2; 93 | return new StringBuilder().append("

").append(question) 94 | .append("

  1. ").append(answer1) 95 | .append("
  2. ").append(answer2) 96 | .append("
").toString(); 97 | } 98 | 99 | @Benchmark 100 | public String strings_3_appendStringBuilderSize() { 101 | String question = title, answer1 = optiontxt1, answer2 = optiontxt2; 102 | int len = 36 + question.length() + answer1.length() + answer2.length(); 103 | return new StringBuilder(len).append("

").append(question) 104 | .append("

  1. ").append(answer1) 105 | .append("
  2. ").append(answer2) 106 | .append("
").toString(); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/StringAppenderConstants.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | public class StringAppenderConstants { 4 | public static final String STRING_BENCHMARKS = "String benchmarks"; 5 | public static final long ID1 = 2734923874L; 6 | public static final long ID2 = 100100L; 7 | public static final String PLUS_VS_CONCAT = "plus vs concat"; 8 | public static final String STRING_BUILDER = "StringBuilder"; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/string/StringIntrinsicsBenchmark.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.string; 2 | 3 | import org.openjdk.jmh.annotations.*; 4 | 5 | import java.lang.reflect.*; 6 | import java.util.*; 7 | import java.util.concurrent.*; 8 | 9 | @Fork(3) 10 | @Warmup(iterations = 30, time = 1) 11 | @Measurement(iterations = 30, time = 1) 12 | @BenchmarkMode(Mode.AverageTime) 13 | @OutputTimeUnit(TimeUnit.NANOSECONDS) 14 | @State(Scope.Benchmark) 15 | public class StringIntrinsicsBenchmark { 16 | private final static boolean TEST_DEDUPLICATION = false; 17 | 18 | @Param({"4", "16", "64", "256", "1024", "65536"}) 19 | private int length; 20 | 21 | private String s1; 22 | private String s2; 23 | private String s3; 24 | private Latin1String l1; 25 | private Latin1String l2; 26 | private Latin1String l3; 27 | private Latin1StringMismatch m1; 28 | private Latin1StringMismatch m2; 29 | private Latin1StringMismatch m3; 30 | private byte[] b1; 31 | private byte[] b2; 32 | private byte[] b3; 33 | 34 | @Setup 35 | public void setup() throws NoSuchFieldException, IllegalAccessException, InterruptedException { 36 | s1 = createString(length); 37 | s2 = createString(length); 38 | s3 = "Wrong length!"; 39 | l1 = new Latin1String(s1); 40 | l2 = new Latin1String(s2); 41 | l3 = new Latin1String(s3); 42 | m1 = new Latin1StringMismatch(s1); 43 | m2 = new Latin1StringMismatch(s2); 44 | m3 = new Latin1StringMismatch(s3); 45 | b1 = l1.value; 46 | b2 = l2.value; 47 | b3 = l3.value; 48 | 49 | if (TEST_DEDUPLICATION) { 50 | Field valueField = String.class.getDeclaredField("value"); 51 | valueField.setAccessible(true); 52 | boolean deduplicated = false; 53 | System.out.print("Check for deduplication .."); 54 | for (int i = 0; i < 10 && !deduplicated; i++) { 55 | System.out.print('.'); 56 | System.gc(); 57 | Thread.sleep(100); 58 | deduplicated = (valueField.get(s1) == valueField.get(s2)); 59 | } 60 | if (deduplicated) { 61 | System.out.println(" deduplicated!"); 62 | } else { 63 | System.out.println(" not deduplicated."); 64 | } 65 | } 66 | } 67 | 68 | private String createString(int length) { 69 | StringBuilder sb = new StringBuilder(); 70 | while (sb.length() < length) { 71 | sb.append("The quick brown fox jumps over the lazy dog. "); 72 | } 73 | sb.setLength(length); 74 | String s = sb.toString(); 75 | if (s.length() != length) throw new AssertionError( 76 | "Incorrect length. Expected " + length + ", actual length=" + s.length() + " s=\"" + s + "\""); 77 | return s; 78 | } 79 | 80 | @Benchmark 81 | public boolean string_equal() { 82 | return s1.equals(s2); 83 | } 84 | 85 | @Benchmark 86 | public boolean string_non_equal() { 87 | return s1.equals(s3); 88 | } 89 | 90 | @Benchmark 91 | public boolean hand_rolled_equal() { 92 | return l1.equals(l2); 93 | } 94 | 95 | @Benchmark 96 | public boolean hand_rolled_non_equal() { 97 | return l1.equals(l3); 98 | } 99 | 100 | @Benchmark 101 | public boolean mismatch_equal() { 102 | return m1.equals(m2); 103 | } 104 | 105 | @Benchmark 106 | public boolean mismatch_non_equal() { 107 | return m1.equals(m3); 108 | } 109 | 110 | public static final class Latin1String { 111 | private final byte[] value; 112 | 113 | public Latin1String(String string) { 114 | byte[] bytes = new byte[string.length()]; 115 | for (int i = 0; i < bytes.length; i++) { 116 | bytes[i] = (byte) string.charAt(i); 117 | } 118 | value = bytes; 119 | } 120 | 121 | @Override 122 | public boolean equals(Object anObject) { 123 | if (this == anObject) { 124 | return true; 125 | } 126 | if (anObject instanceof Latin1String) { 127 | Latin1String aString = (Latin1String) anObject; 128 | return equals(value, aString.value); 129 | } 130 | return false; 131 | } 132 | 133 | // Copied from java.lang.StringLatin1.equals(byte[], byte[]) 134 | private static boolean equals(byte[] value, byte[] other) { 135 | if (value.length == other.length) { 136 | for (int i = 0; i < value.length; i++) { 137 | if (value[i] != other[i]) { 138 | return false; 139 | } 140 | } 141 | return true; 142 | } 143 | return false; 144 | } 145 | 146 | @Override 147 | public int hashCode() { 148 | return Arrays.hashCode(value); 149 | } 150 | } 151 | 152 | public static final class Latin1StringMismatch { 153 | private final byte[] value; 154 | 155 | public Latin1StringMismatch(String string) { 156 | byte[] bytes = new byte[string.length()]; 157 | for (int i = 0; i < bytes.length; i++) { 158 | bytes[i] = (byte) string.charAt(i); 159 | } 160 | value = bytes; 161 | } 162 | 163 | @Override 164 | public boolean equals(Object anObject) { 165 | if (this == anObject) { 166 | return true; 167 | } 168 | if (anObject instanceof Latin1StringMismatch) { 169 | Latin1StringMismatch aString = (Latin1StringMismatch) anObject; 170 | return equals(value, aString.value); 171 | } 172 | return false; 173 | } 174 | 175 | // Probably how it is implemented in the intrinsic 176 | private static boolean equals(byte[] value, byte[] other) { 177 | if (value.length == other.length) { 178 | return Arrays.mismatch(value, other) == -1; 179 | } 180 | return false; 181 | } 182 | 183 | @Override 184 | public int hashCode() { 185 | return Arrays.hashCode(value); 186 | } 187 | } 188 | 189 | } 190 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/util/ByteWatcherSingleThread.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.util; 2 | 3 | import javax.management.*; 4 | import java.lang.management.*; 5 | import java.util.concurrent.atomic.*; 6 | 7 | public class ByteWatcherSingleThread { 8 | private static final String ALLOCATED = " allocated "; 9 | private static final String GET_THREAD_ALLOCATED_BYTES = 10 | "getThreadAllocatedBytes"; 11 | private static final String[] SIGNATURE = 12 | new String[]{long.class.getName()}; 13 | private static final MBeanServer mBeanServer; 14 | private static final ObjectName name; 15 | 16 | private final String threadName; 17 | private final Thread thread; 18 | 19 | private final Object[] PARAMS; 20 | private final AtomicLong allocated = new AtomicLong(); 21 | private final long MEASURING_COST_IN_BYTES; // usually 336 22 | private final long tid; 23 | private final boolean checkThreadSafety; 24 | 25 | static { 26 | try { 27 | name = new ObjectName( 28 | ManagementFactory.THREAD_MXBEAN_NAME); 29 | mBeanServer = ManagementFactory.getPlatformMBeanServer(); 30 | } catch (MalformedObjectNameException e) { 31 | throw new ExceptionInInitializerError(e); 32 | } 33 | } 34 | 35 | public ByteWatcherSingleThread() { 36 | this(Thread.currentThread(), true); 37 | } 38 | 39 | public ByteWatcherSingleThread(Thread thread) { 40 | this(thread, false); 41 | } 42 | 43 | private ByteWatcherSingleThread( 44 | Thread thread, boolean checkThreadSafety) { 45 | this.checkThreadSafety = checkThreadSafety; 46 | this.tid = thread.getId(); 47 | this.thread = thread; 48 | threadName = thread.getName(); 49 | PARAMS = new Object[]{tid}; 50 | 51 | long calibrate = threadAllocatedBytes(); 52 | // calibrate 53 | for (int repeats = 0; repeats < 10; repeats++) { 54 | for (int i = 0; i < 10000; i++) { 55 | // run a few loops to allow for startup anomalies 56 | calibrate = threadAllocatedBytes(); 57 | } 58 | try { 59 | Thread.sleep(50); 60 | } catch (InterruptedException e) { 61 | Thread.currentThread().interrupt(); 62 | break; 63 | } 64 | } 65 | MEASURING_COST_IN_BYTES = threadAllocatedBytes() - calibrate; 66 | reset(); 67 | } 68 | 69 | public long getMeasuringCostInBytes() { 70 | return MEASURING_COST_IN_BYTES; 71 | } 72 | 73 | public void reset() { 74 | checkThreadSafety(); 75 | 76 | allocated.set(threadAllocatedBytes()); 77 | } 78 | 79 | long threadAllocatedBytes() { 80 | try { 81 | return (Long) mBeanServer.invoke( 82 | name, 83 | GET_THREAD_ALLOCATED_BYTES, 84 | PARAMS, 85 | SIGNATURE 86 | ); 87 | } catch (Exception e) { 88 | throw new IllegalArgumentException(e); 89 | } 90 | } 91 | 92 | /** 93 | * Calculates the number of bytes allocated since the last 94 | * reset(). 95 | */ 96 | public long calculateAllocations() { 97 | checkThreadSafety(); 98 | long mark1 = ((threadAllocatedBytes() - 99 | MEASURING_COST_IN_BYTES) - allocated.get()); 100 | return mark1; 101 | } 102 | 103 | private void checkThreadSafety() { 104 | if (checkThreadSafety && 105 | tid != Thread.currentThread().getId()) 106 | throw new IllegalStateException( 107 | "AllocationMeasure must not be " + 108 | "used over more than 1 thread."); 109 | } 110 | 111 | public Thread getThread() { 112 | return thread; 113 | } 114 | 115 | public String toString() { 116 | return thread.getName() + ALLOCATED + calculateAllocations(); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/perf/util/Memory.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.perf.util; 2 | 3 | import java.util.*; 4 | 5 | public enum Memory { 6 | BYTES { 7 | public double toBytes(double d) { 8 | return d; 9 | } 10 | 11 | public double toKiloBytes(double d) { 12 | return toBytes(d) / 1024; 13 | } 14 | 15 | public double toMegaBytes(double d) { 16 | return toKiloBytes(d) / 1024; 17 | } 18 | 19 | public double toGigaBytes(double d) { 20 | return toMegaBytes(d) / 1024; 21 | } 22 | 23 | public double toTeraBytes(double d) { 24 | return toGigaBytes(d) / 1024; 25 | } 26 | }, 27 | KILOBYTES { 28 | public double toBytes(double d) { 29 | return toKiloBytes(d) * 1024; 30 | } 31 | 32 | public double toKiloBytes(double d) { 33 | return d; 34 | } 35 | 36 | public double toMegaBytes(double d) { 37 | return toKiloBytes(d) / 1024; 38 | } 39 | 40 | public double toGigaBytes(double d) { 41 | return toMegaBytes(d) / 1024; 42 | } 43 | 44 | public double toTeraBytes(double d) { 45 | return toGigaBytes(d) / 1024; 46 | } 47 | }, 48 | MEGABYTES { 49 | public double toBytes(double d) { 50 | return toKiloBytes(d) * 1024; 51 | } 52 | 53 | public double toKiloBytes(double d) { 54 | return toMegaBytes(d) * 1024; 55 | } 56 | 57 | public double toMegaBytes(double d) { 58 | return d; 59 | } 60 | 61 | public double toGigaBytes(double d) { 62 | return toMegaBytes(d) / 1024; 63 | } 64 | 65 | public double toTeraBytes(double d) { 66 | return toGigaBytes(d) / 1024; 67 | } 68 | }, 69 | GIGABYTES { 70 | public double toBytes(double d) { 71 | return toKiloBytes(d) * 1024; 72 | } 73 | 74 | public double toKiloBytes(double d) { 75 | return toMegaBytes(d) * 1024; 76 | } 77 | 78 | public double toMegaBytes(double d) { 79 | return toGigaBytes(d) * 1024; 80 | } 81 | 82 | public double toGigaBytes(double d) { 83 | return d; 84 | } 85 | 86 | public double toTeraBytes(double d) { 87 | return toGigaBytes(d) / 1024; 88 | } 89 | }, 90 | TERABYTES { 91 | public double toBytes(double d) { 92 | return toKiloBytes(d) * 1024; 93 | } 94 | 95 | public double toKiloBytes(double d) { 96 | return toMegaBytes(d) * 1024; 97 | } 98 | 99 | public double toMegaBytes(double d) { 100 | return toGigaBytes(d) * 1024; 101 | } 102 | 103 | public double toGigaBytes(double d) { 104 | return toTeraBytes(d) * 1024; 105 | } 106 | 107 | public double toTeraBytes(double d) { 108 | return d; 109 | } 110 | }; 111 | 112 | public abstract double toBytes(double d); 113 | 114 | public abstract double toKiloBytes(double d); 115 | 116 | public abstract double toMegaBytes(double d); 117 | 118 | public abstract double toGigaBytes(double d); 119 | 120 | public abstract double toTeraBytes(double d); 121 | 122 | public static String format(double d, Memory unit, int decimals) { 123 | String unitStr; 124 | double val; 125 | double bytes = unit.toBytes(d); 126 | if (bytes < 1024) { 127 | val = bytes; 128 | unitStr = "B"; 129 | } else if (bytes < 1024 * 1024) { 130 | val = BYTES.toKiloBytes(bytes); 131 | unitStr = "KB"; 132 | } else if (bytes < 1024 * 1024 * 1024) { 133 | val = BYTES.toMegaBytes(bytes); 134 | unitStr = "MB"; 135 | } else if (bytes < 1024 * 1024 * 1024 * 1024L) { 136 | val = BYTES.toGigaBytes(bytes); 137 | unitStr = "GB"; 138 | } else { 139 | val = BYTES.toTeraBytes(bytes); 140 | unitStr = "TB"; 141 | } 142 | return String.format(Locale.US, "%." + decimals + "f%s", val, unitStr); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/BytesCountAppending.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import eu.javaspecialists.perf.util.*; 4 | 5 | /* 6 | Java 64-bit Compressed Oops Compact Strings on: 7 |

What is Faster?

  1. Using + to add Strings
  2. Using StringAppender
8 | byte[]: 93 characters 9 | 12 + 4 + 93 = 109 ≈ 112 10 | String: 11 | 12 + 4 + 1 + 4 = 21 ≈ 24 12 | Total: 136 13 | 14 | Compact Strings off: 15 |

What is Faster?

  1. Using + to add Strings
  2. Using StringAppender
16 | byte[]: 74 characters 17 | 12 + 4 + 93*2 = 202 ≈ 208 18 | String: 19 | 12 + 4 + 1 + 4 = 21 ≈ 24 20 | Total: 232 21 | 22 | 23 | Standard results 24 | concat_bytes_strings = 136 25 | sb_bytes_strings = 136 26 | sb_sized_bytes_strings = 136 27 | format_strings = 1384 28 | concat_bytes_mixed = 136 29 | sb_bytes_mixed = 496 30 | sb_sized_bytes_mixed = 272 31 | format_mixed = 1384 32 | */ 33 | public class BytesCountAppending { 34 | public static void main(String... args) { 35 | String question = "String benchmarks"; 36 | String answer1 = "plus vs concat"; 37 | String answer2 = "StringBuilder"; 38 | ByteWatcherSingleThread bw = new ByteWatcherSingleThread(); 39 | for (int i = 0; i < 1000000; i++) { 40 | concat(question, answer1, answer2); 41 | sb(question, answer1, answer2); 42 | sb_sized(question, answer1, answer2); 43 | format(question, answer1, answer2); 44 | 45 | concat(question, answer1, (Object) answer2); 46 | sb(question, answer1, (Object) answer2); 47 | sb_sized(question, answer1, (Object) answer2); 48 | format(question, answer1, (Object) answer2); 49 | } 50 | 51 | bw.reset(); 52 | concat(question, answer1, answer2); 53 | long concat_bytes_strings = bw.calculateAllocations(); 54 | 55 | bw.reset(); 56 | sb(question, answer1, answer2); 57 | long sb_bytes_strings = bw.calculateAllocations(); 58 | 59 | bw.reset(); 60 | sb_sized(question, answer1, answer2); 61 | long sb_sized_bytes_strings = bw.calculateAllocations(); 62 | 63 | bw.reset(); 64 | format(question, answer1, answer2); 65 | long format_strings = bw.calculateAllocations(); 66 | 67 | bw.reset(); 68 | concat(question, answer1, (Object) answer2); 69 | long concat_bytes_mixed = bw.calculateAllocations(); 70 | 71 | bw.reset(); 72 | sb(question, answer1, (Object) answer2); 73 | long sb_bytes_mixed = bw.calculateAllocations(); 74 | 75 | bw.reset(); 76 | sb_sized(question, answer1, (Object) answer2); 77 | long sb_sized_bytes_mixed = bw.calculateAllocations(); 78 | 79 | bw.reset(); 80 | format(question, answer1, (Object) answer2); 81 | long format_mixed = bw.calculateAllocations(); 82 | 83 | System.out.println("concat_bytes_strings = " + concat_bytes_strings); 84 | System.out.println("sb_bytes_strings = " + sb_bytes_strings); 85 | System.out.println("sb_sized_bytes_strings = " + sb_sized_bytes_strings); 86 | System.out.println("format_strings = " + format_strings); 87 | System.out.println("concat_bytes_mixed = " + concat_bytes_mixed); 88 | System.out.println("sb_bytes_mixed = " + sb_bytes_mixed); 89 | System.out.println("sb_sized_bytes_mixed = " + sb_sized_bytes_mixed); 90 | System.out.println("format_mixed = " + format_mixed); 91 | } 92 | 93 | public static String concat(String question, String answer1, String answer2) { 94 | return "

" + question + "

  1. " + answer1 + 95 | "
  2. " + answer2 + "
"; 96 | } 97 | 98 | public static String sb(String question, String answer1, String answer2) { 99 | return new StringBuilder().append("

").append(question) 100 | .append("

  1. ").append(answer1) 101 | .append("
  2. ").append(answer2) 102 | .append("
").toString(); 103 | } 104 | 105 | public static String sb_sized(String question, String answer1, String answer2) { 106 | int len = 36 + question.length() + answer1.length() + answer2.length(); 107 | return new StringBuilder(len).append("

").append(question) 108 | .append("

  1. ").append(answer1) 109 | .append("
  2. ").append(answer2) 110 | .append("
").toString(); 111 | } 112 | 113 | public static String format(String question, String answer1, String answer2) { 114 | return String.format("

%s

  1. %s
  2. %s
", question, answer1, answer2); 115 | } 116 | 117 | 118 | public static String concat(String question, String answer1, Object answer2) { 119 | return "

" + question + "

  1. " + answer1 + 120 | "
  2. " + answer2 + "
"; 121 | } 122 | 123 | public static String sb(String question, String answer1, Object answer2) { 124 | return new StringBuilder().append("

").append(question) 125 | .append("

  1. ").append(answer1) 126 | .append("
  2. ").append(answer2) 127 | .append("
").toString(); 128 | } 129 | 130 | public static String sb_sized(String question, String answer1, Object answer2) { 131 | int len = 36 + question.length() + answer1.length() + answer2.toString().length(); 132 | return new StringBuilder(len).append("

").append(question) 133 | .append("

  1. ").append(answer1) 134 | .append("
  2. ").append(answer2) 135 | .append("
").toString(); 136 | } 137 | 138 | public static String format(String question, String answer1, Object answer2) { 139 | return String.format("

%s

  1. %s
  2. %s
", question, answer1, answer2); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/DeduplicationDemo.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import java.lang.reflect.*; 4 | 5 | public class DeduplicationDemo { 6 | public static void main(String... args) throws Exception { 7 | char[] heinz = {'h', 'e', 'i', 'n', 'z'}; 8 | String[] s = {new String(heinz), new String(heinz),}; 9 | Field value = String.class.getDeclaredField("value"); 10 | value.setAccessible(true); 11 | System.out.println("Before GC"); 12 | System.out.println(value.get(s[0])); 13 | System.out.println(value.get(s[1])); 14 | System.gc(); 15 | Thread.sleep(100); 16 | System.out.println("After GC"); 17 | System.out.println(value.get(s[0])); 18 | System.out.println(value.get(s[1])); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/IntToStringLazy.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import java.lang.management.*; 4 | 5 | public class IntToStringLazy { 6 | private static String s; 7 | private static long bestTime = Long.MAX_VALUE; 8 | 9 | public static void main(String... args) { 10 | RuntimeMXBean rbean = ManagementFactory.getRuntimeMXBean(); 11 | System.out.println("IntToStringLazy on " + 12 | rbean.getVmVendor() + ", " + 13 | rbean.getVmName() + ", Java " + 14 | rbean.getVmVersion() + 15 | " : vm args " + rbean.getInputArguments()); 16 | 17 | for (int i = 0; i < 10; i++) { 18 | test(); 19 | } 20 | System.out.println("s = " + s); 21 | System.out.println("bestTime = " + bestTime / 1000000); 22 | System.out.println(); 23 | } 24 | 25 | private static void test() { 26 | long time = System.nanoTime(); 27 | try { 28 | for (int i = 0; i < 100000000; i++) { 29 | s = "" + i; 30 | } 31 | } finally { 32 | time = System.nanoTime() - time; 33 | bestTime = Math.min(bestTime, time); 34 | System.out.printf("time = %dms%n", (time / 1000000)); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/IntToStringStudious.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import java.lang.management.*; 4 | 5 | public class IntToStringStudious { 6 | private static String s; 7 | private static long bestTime = Long.MAX_VALUE; 8 | 9 | public static void main(String... args) { 10 | RuntimeMXBean rbean = ManagementFactory.getRuntimeMXBean(); 11 | System.out.println("IntToStringStudious on " + 12 | rbean.getVmVendor() + ", " + 13 | rbean.getVmName() + ", Java " + 14 | rbean.getVmVersion() + 15 | " : vm args " + rbean.getInputArguments()); 16 | 17 | for (int i = 0; i < 10; i++) { 18 | test(); 19 | } 20 | System.out.println("s = " + s); 21 | System.out.println("bestTime = " + bestTime / 1000000); 22 | System.out.println(); 23 | } 24 | 25 | private static void test() { 26 | long time = System.nanoTime(); 27 | try { 28 | for (int i = 0; i < 100000000; i++) { 29 | s = Integer.toString(i); 30 | } 31 | } finally { 32 | time = System.nanoTime() - time; 33 | bestTime = Math.min(bestTime, time); 34 | System.out.printf("time = %dms%n", (time / 1000000)); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/Key.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | public class Key { 4 | private final int id; 5 | 6 | public Key(int id) { 7 | this.id = id; 8 | } 9 | 10 | public int hashCode() { 11 | try { 12 | Thread.sleep(100); // now THIS is slow 13 | } catch (InterruptedException e) { 14 | Thread.currentThread().interrupt(); 15 | } 16 | return id; 17 | } 18 | 19 | public boolean equals(Object obj) { 20 | if (!(obj instanceof Key)) return false; 21 | return id == ((Key) obj).id; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/KeyDemo.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import java.util.*; 4 | import java.util.concurrent.*; 5 | 6 | public class KeyDemo { 7 | public static void main(String... args) { 8 | Map keys = new ConcurrentHashMap(); 9 | long time = System.nanoTime(); 10 | try { 11 | for (int i = 0; i < 30; i++) { 12 | keys.put(new Key(i), "" + i); 13 | } 14 | } finally { 15 | time = System.nanoTime() - time; 16 | System.out.printf("time = %dms%n", (time / 1000000)); 17 | } 18 | 19 | time = System.nanoTime(); 20 | try { 21 | for (int i = 0; i < 30; i++) { 22 | System.out.println(keys.get(new Key(i))); 23 | } 24 | } finally { 25 | time = System.nanoTime() - time; 26 | System.out.printf("time = %dms%n", (time / 1000000)); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/LargestString.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | public class LargestString { 4 | public static void main(String... args) { 5 | StringBuilder sb = new StringBuilder(2000000000); 6 | sb.append("hello"); 7 | String s1 = sb.toString(); 8 | System.out.println("s1.length() = " + s1.length()); 9 | sb.append("hełło"); 10 | String s2 = sb.toString(); 11 | System.out.println("s2.length() = " + s1.length()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/NumberToStringByteCount.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import eu.javaspecialists.perf.util.*; 4 | 5 | public class NumberToStringByteCount { 6 | private int intVal = 1640531527; 7 | private long longVal = -8454749669228202880L; 8 | 9 | public String int_plus() { 10 | return "" + intVal; 11 | } 12 | 13 | public String int_toString() { 14 | return Integer.toString(intVal); 15 | } 16 | 17 | public String long_plus() { 18 | return "" + longVal; 19 | } 20 | 21 | public String long_toString() { 22 | return Long.toString(longVal); 23 | } 24 | 25 | public static void main(String... args) { 26 | NumberToStringByteCount bc = new NumberToStringByteCount(); 27 | 28 | ByteWatcherSingleThread bw = new ByteWatcherSingleThread(); 29 | for (int i = 0; i < 1000000; i++) { 30 | bc.int_plus(); 31 | bc.int_toString(); 32 | bc.long_plus(); 33 | bc.long_toString(); 34 | } 35 | 36 | bw.reset(); 37 | bc.int_plus(); 38 | long int_plus_bytes = bw.calculateAllocations(); 39 | 40 | bw.reset(); 41 | bc.int_toString(); 42 | long int_toString_bytes = bw.calculateAllocations(); 43 | 44 | bw.reset(); 45 | bc.long_plus(); 46 | long long_plus_bytes = bw.calculateAllocations(); 47 | 48 | bw.reset(); 49 | bc.long_toString(); 50 | long long_toString_bytes = bw.calculateAllocations(); 51 | 52 | System.out.println("int_plus_bytes = " + int_plus_bytes); 53 | System.out.println("int_toString_bytes = " + int_toString_bytes); 54 | System.out.println("long_plus_bytes = " + long_plus_bytes); 55 | System.out.println("long_toString_bytes = " + long_toString_bytes); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/PXMLTag.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import java.util.*; 4 | 5 | /* 6 | This odd case 7 | type 'java.util.Map' 8 | currentPrimitiveType 'java.lang.String' 9 | They are equal? false 10 | They are compared 9 11 | m_type 'java.util.Map' 12 | m_primitiveType[i] 'java.lang.String' 13 | They are equal? false 14 | They are compared 9 15 | java.util.Map not really primitive! 16 | 17 | My program terminates on 1.7.0.45-64 but works fine on 1.7.0.25-64. 18 | Fails also on 1.7.0_40 19 | Failed also on 1.8.0_31 20 | 21 | did not happen with -XX:DisableIntrinsic=_compareTo 22 | 23 | List of Java 8 intrinsics: https://gist.github.com/apangin/7a9b7062a4bd0cd41fcc 24 | List of Java 9 intrinsics: https://gist.github.com/apangin/8bc69f06879a86163e490a61931b37e8 25 | 26 | 27 | */ 28 | public class PXMLTag { 29 | public String m_type; 30 | public static Random m_random = new Random(); 31 | private static String[] m_primitiveTypes = {"java.lang.String", 32 | "boolean", 33 | "int", 34 | "long", 35 | "float", 36 | "short"}; 37 | 38 | private static String[] m_allTypes = {"java.lang.String", 39 | "boolean", 40 | "int", 41 | "long", 42 | "float", 43 | "java.util.Vector", 44 | "java.util.Map", 45 | "short"}; 46 | 47 | public PXMLTag() { 48 | super(); 49 | } 50 | 51 | public boolean isPrimitiveType() { 52 | for (int i = 0; i < m_primitiveTypes.length; i++) { 53 | String type = m_type; 54 | String primitiveType = m_primitiveTypes[i]; 55 | if (type.compareTo(primitiveType) == 0) { 56 | return true; 57 | } 58 | } 59 | return false; 60 | } 61 | 62 | public static void main(String[] args) { 63 | int threads = 1; 64 | if (args.length == 1) { 65 | threads = Integer.parseInt(args[0]); 66 | } 67 | for (int i = 0; i < threads; i++) { 68 | Thread t = createThread(); 69 | t.start(); 70 | } 71 | } 72 | 73 | private static Thread createThread() { 74 | return new Thread(new Runnable() { 75 | 76 | @Override 77 | public void run() { 78 | while (true) { 79 | PXMLTag tag = new PXMLTag(); 80 | tag.m_type = getRandomType(); 81 | if (tag.isPrimitiveType() && notReallyPrimitiveType(tag.m_type)) { 82 | System.out.println(tag.m_type + " not really primitive!"); 83 | System.exit(0); 84 | } 85 | try { 86 | Thread.sleep(m_random.nextInt(100)); 87 | } catch (InterruptedException e) { 88 | // TODO Auto-generated catch block 89 | e.printStackTrace(); 90 | } 91 | } 92 | } 93 | 94 | private boolean notReallyPrimitiveType(String m_type) { 95 | return m_type.contains("Vector") || m_type.contains("Map"); 96 | } 97 | 98 | private String getRandomType() { 99 | return m_allTypes[m_random.nextInt(m_allTypes.length)]; 100 | } 101 | }); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/StringAppender.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | public class StringAppender { 4 | private static String leak; 5 | 6 | public static String appendBasic( 7 | String question, String answer1, String answer2) { 8 | return "

" + question + "

  1. " + answer1 + 9 | "
  2. " + answer2 + "
"; 10 | } 11 | 12 | public static String appendStringBuilder( 13 | String question, String answer1, String answer2) { 14 | return new StringBuilder().append("

").append(question) 15 | .append("

  1. ").append(answer1) 16 | .append("
  2. ").append(answer2) 17 | .append("
").toString(); 18 | } 19 | 20 | public static String appendStringBuilderSize( 21 | String question, String answer1, String answer2) { 22 | int len = 36 + question.length() + answer1.length() + answer2.length(); 23 | return new StringBuilder(len).append("

").append(question) 24 | .append("

  1. ").append(answer1) 25 | .append("
  2. ").append(answer2) 26 | .append("
").toString(); 27 | } 28 | 29 | // don't show this option 30 | public static String appendFormat( 31 | String question, String answer1, String answer2) { 32 | return String.format("

%s

  1. %s
  2. %s
", question, answer1, answer2); 33 | } 34 | 35 | 36 | public static void main(String... args) { 37 | String question = "What is the question?"; 38 | String answer1 = "Answer 1"; 39 | String answer2 = "Answer 2"; 40 | for (int i = 0; i < 10; i++) { 41 | test(question, answer1, answer2); 42 | } 43 | } 44 | private static void test(String question, String answer1, String answer2) { 45 | long time = System.nanoTime(); 46 | try { 47 | for (int i = 0; i < 20000000; i++) { 48 | leak = appendFormat(question, answer1, answer2); 49 | } 50 | } finally { 51 | time = System.nanoTime() - time; 52 | System.out.printf("time = %dms%n", (time / 1000000)); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/StringAppenderByteCount.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import eu.javaspecialists.perf.util.*; 4 | 5 | import java.text.*; 6 | import java.util.*; 7 | 8 | import static eu.javaspecialists.perf.string.StringAppenderConstants.*; 9 | 10 | public class StringAppenderByteCount { 11 | private static volatile Object leak; 12 | private String title = STRING_BENCHMARKS; 13 | private long id1 = ID1; 14 | private long id2 = ID2; 15 | private String optiontxt1 = PLUS_VS_CONCAT; 16 | private String optiontxt2 = STRING_BUILDER; 17 | 18 | public String plus() { 19 | // 4 16 5 12 5 10 20 | return "

" + title + "

  • " + id1 + " " + optiontxt1 + "
  • " + id2 + " " + optiontxt2 + "
"; 21 | } 22 | 23 | public String concat() { 24 | return "

".concat(title).concat("

  • ").concat(Long.toString(id1)).concat(" ").concat(optiontxt1) 25 | .concat("
  • ").concat(Long.toString(id2)).concat(" ").concat(optiontxt2).concat("
"); 26 | } 27 | 28 | public String format() { 29 | return String.format("

%s

  • %d %s
  • %d %s
", title, id1, optiontxt1, id2, optiontxt2); 30 | } 31 | 32 | public String sb() { 33 | return new StringBuilder() 34 | .append("

").append(title).append("

  • ").append(id1).append(" ").append(optiontxt1) 35 | .append("
  • ").append(id2).append(" ").append(optiontxt2).append("
").toString(); 36 | } 37 | 38 | public String sb_sized() { 39 | return new StringBuilder(52 + title.length() + 10 + optiontxt1.length() + 6 + optiontxt2.length()) 40 | .append("

").append(title).append("

  • ").append(id1).append(" ").append(optiontxt1) 41 | .append("
  • ").append(id2).append(" ").append(optiontxt2).append("
").toString(); 42 | } 43 | 44 | public String appendBasic() { 45 | String question = title, answer1 = optiontxt1, answer2 = optiontxt2; 46 | return "

" + question + "

  1. " + answer1 + 47 | "
  2. " + answer2 + "
"; 48 | } 49 | 50 | public String appendStringBuilder() { 51 | String question = title, answer1 = optiontxt1, answer2 = optiontxt2; 52 | return new StringBuilder().append("

").append(question) 53 | .append("

  1. ").append(answer1) 54 | .append("
  2. ").append(answer2) 55 | .append("
").toString(); 56 | } 57 | 58 | public String appendStringBuilderSize() { 59 | String question = title, answer1 = optiontxt1, answer2 = optiontxt2; 60 | int len = 36 + question.length() + answer1.length() + answer2.length(); 61 | return new StringBuilder(len).append("

").append(question) 62 | .append("

  1. ").append(answer1) 63 | .append("
  2. ").append(answer2) 64 | .append("
").toString(); 65 | } 66 | 67 | public static void main(String... args) throws InterruptedException { 68 | StringAppenderByteCount bc = new StringAppenderByteCount(); 69 | 70 | ByteWatcherSingleThread bw = new ByteWatcherSingleThread(); 71 | for (int i = 0; i < 1000000; i++) { 72 | leak = bc.object(); 73 | leak = bc.makeLong(); 74 | leak = bc.plus(); 75 | leak = bc.sb_sized(); 76 | leak = bc.sb(); 77 | leak = bc.concat(); 78 | leak = bc.format(); 79 | } 80 | 81 | for (int i = 0; i < 5; i++) { 82 | test(bc, bw); 83 | System.out.println(); 84 | Thread.sleep(1000); 85 | } 86 | 87 | } 88 | private static void test(StringAppenderByteCount bc, ByteWatcherSingleThread bw) { 89 | bw.reset(); 90 | leak = bc.object(); 91 | long object_bytes = bw.calculateAllocations(); 92 | 93 | bw.reset(); 94 | leak = bc.makeLong(); 95 | long long_bytes = bw.calculateAllocations(); 96 | 97 | bw.reset(); 98 | leak = bc.plus(); 99 | long plus_bytes = bw.calculateAllocations(); 100 | 101 | bw.reset(); 102 | leak = bc.sb_sized(); 103 | long sb_sized_bytes = bw.calculateAllocations(); 104 | 105 | bw.reset(); 106 | leak = bc.sb(); 107 | long sb_bytes = bw.calculateAllocations(); 108 | 109 | bw.reset(); 110 | leak = bc.concat(); 111 | long concat_bytes = bw.calculateAllocations(); 112 | 113 | bw.reset(); 114 | leak = bc.format(); 115 | long format_bytes = bw.calculateAllocations(); 116 | 117 | if (object_bytes != 16) throw new AssertionError(); 118 | if (long_bytes != 24) throw new AssertionError(); 119 | System.out.println("plus_bytes = " + plus_bytes); 120 | System.out.println("sb_sized_bytes = " + sb_sized_bytes); 121 | System.out.println("sb_bytes = " + sb_bytes); 122 | System.out.println("concat_bytes = " + concat_bytes); 123 | System.out.println("format_bytes = " + format_bytes); 124 | } 125 | private Object object() { 126 | return new Object(); 127 | } 128 | private Long makeLong() { 129 | return 42000000000000L; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/StringLayout.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground; 2 | 3 | import org.openjdk.jol.info.*; 4 | 5 | public class StringLayout { 6 | public static void main(String[] args) { 7 | System.out.println(ClassLayout.parseClass(String.class).toPrintable()); 8 | System.out.println(GraphLayout.parseInstance("").toPrintable()); 9 | System.out.println(GraphLayout.parseInstance("Hello, world!").toPrintable()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/hasher/BruteForceBase.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground.hasher; 2 | 3 | public abstract class BruteForceBase { 4 | protected static final byte[] alphabet = new byte[26 * 2]; 5 | protected static long number; 6 | private final static boolean DEBUG = false; 7 | protected static long time; 8 | 9 | static { 10 | for (int i = 0; i < 26; i++) { 11 | alphabet[i] = (byte) ('A' + i); 12 | alphabet[i + 26] = (byte) ('a' + i); 13 | } 14 | System.out.println("alphabet = " + new String(alphabet)); 15 | time = System.nanoTime(); 16 | } 17 | 18 | protected static void checkProgress() { 19 | if (DEBUG) { 20 | if (++number % 10000000000L == 0) { 21 | System.out.println("number = " + number); 22 | time = System.nanoTime() - time; 23 | System.out.println("start = " + time / 1000000 + "ms"); 24 | time = System.nanoTime(); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/hasher/BruteForceNestedLoops.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground.hasher; 2 | 3 | /** 4 | * Bad style - recursion is more elegant - but this is faster 5 | */ 6 | /* 7 | number = 10000000000 8 | start = 26653ms 9 | */ 10 | public class BruteForceNestedLoops extends BruteForceBase { 11 | public static void main(String... args) { 12 | for (byte i0 : alphabet) { 13 | int h0 = i0; 14 | for (byte i1 : alphabet) { 15 | int h1 = h0 * 31 + i1; 16 | for (byte i2 : alphabet) { 17 | int h2 = h1 * 31 + i2; 18 | for (byte i3 : alphabet) { 19 | int h3 = h2 * 31 + i3; 20 | for (byte i4 : alphabet) { 21 | int h4 = h3 * 31 + i4; 22 | for (byte i5 : alphabet) { 23 | int h5 = h4 * 31 + i5; 24 | for (byte i6 : alphabet) { 25 | int h6 = h5 * 31 + i6; 26 | if (h6 == 0) { 27 | byte[] is = {i0, i1, i2, i3, i4, i5, i6}; 28 | System.out.println(new String(is)); 29 | } 30 | checkProgress(); 31 | } 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/hasher/BruteForceParallel.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground.hasher; 2 | 3 | /** 4 | * Bad style - recursion is more elegant - but this is faster 5 | */ 6 | public class BruteForceParallel extends BruteForceBase { 7 | public static void main(String... args) { 8 | for (int i = 0; i < 4; i++) { 9 | final int from = i * 13; 10 | final int to = from + 13; 11 | new Thread(new Runnable() { 12 | public void run() { 13 | for (int index = from; index < to; index++) { 14 | byte i0 = alphabet[index]; 15 | int h0 = i0; 16 | for (byte i1 : alphabet) { 17 | int h1 = h0 * 31 + i1; 18 | for (byte i2 : alphabet) { 19 | int h2 = h1 * 31 + i2; 20 | for (byte i3 : alphabet) { 21 | int h3 = h2 * 31 + i3; 22 | for (byte i4 : alphabet) { 23 | int h4 = h3 * 31 + i4; 24 | for (byte i5 : alphabet) { 25 | int h5 = h4 * 31 + i5; 26 | for (byte i6 : alphabet) { 27 | int h6 = h5 * 31 + i6; 28 | if (h6 == 0) { 29 | byte[] is = {i0, i1, i2, i3, i4, i5, i6}; 30 | System.out.println(new String(is)); 31 | } 32 | // checkProgress(); <-- not thread-safe 33 | } 34 | } 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | }).start(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/hasher/BruteForceRecursive.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground.hasher; 2 | 3 | /** 4 | * Unhashing the String aka Darcy can produce a String with any 5 | * hashCode, but not in printable characters. 6 | * See also https://blogs.oracle.com/darcy/unhashing-a-string 7 | */ 8 | /* 9 | number = 10000000000 10 | start = 100827ms 11 | */ 12 | public class BruteForceRecursive extends BruteForceBase { 13 | public static void main(String... args) { 14 | // no point checking smaller than 7 characters as it is 15 | // mathematically impossible to get a String with smaller 16 | // size and character in range [A-Za-z] with hashCode==0 17 | long time = System.nanoTime(); 18 | try { 19 | findZeroHashCodes(new byte[7], 0); 20 | } finally { 21 | time = System.nanoTime() - time; 22 | System.out.printf("start = %dms%n", (time / 1000000)); 23 | } 24 | } 25 | 26 | private static void findZeroHashCodes(byte[] value, int pos) { 27 | if (pos == value.length) { 28 | if (hashCode(value) == 0) 29 | System.out.println(new String(value)); 30 | checkProgress(); 31 | return; 32 | } 33 | for (byte i : alphabet) { 34 | value[pos] = i; 35 | findZeroHashCodes(value, pos + 1); 36 | } 37 | } 38 | 39 | public static int hashCode(byte[] value) { 40 | int h = 0; 41 | for (byte v : value) { 42 | h = 31 * h + (v & 0xff); 43 | } 44 | return h; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/hasher/BruteForceRecursive2.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground.hasher; 2 | 3 | import java.util.*; 4 | 5 | /* 6 | number = 10000000000 7 | start = 40056ms 8 | */ 9 | public class BruteForceRecursive2 extends BruteForceBase { 10 | public static void main(String... args) { 11 | byte[] is = new byte[7]; 12 | Arrays.fill(is, (byte) '!'); 13 | check(0, 0, is); 14 | } 15 | 16 | private static void check(int depth, int h, byte[] is) { 17 | if (depth == 7) { 18 | if (h == 0) { 19 | System.out.println(new String(is)); 20 | } 21 | checkProgress(); 22 | return; 23 | } 24 | 25 | for (byte i : alphabet) { 26 | is[depth] = i; 27 | check(depth + 1, h * 31 + i, is); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/hasher/HashCodeZero.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground.hasher; 2 | 3 | import java.util.*; 4 | 5 | // Java 6 get() is linear 6 | // Java 7 get() is also linear, but special case for Strings if you us -Djdk.map.althashing.threshold=512 7 | // hashes differently 8 | // Java 8+ get() is logarithmic when bucket has a lot of clashes 9 | 10 | // source code is compatible with Java 6 11 | public class HashCodeZero { 12 | private static final String[] zeroHashCodes = { 13 | "ARbyguv", "ARbygvW", "ARbyhVv", "ARbyhWW", "ARbzHuv", "ARbzHvW", "ARbzIVv", "ARbzIWW", 14 | "ARcZguv", "ARcZgvW", "ARcZhVv", "ARcZhWW", "ASCyguv", "ASCygvW", "ASCyhVv", "ASCyhWW", 15 | "ASCzHuv", "ASCzHvW", "ASCzIVv", "ASCzIWW", "ASDZguv", "ASDZgvW", "ASDZhVv", "ASDZhWW", 16 | }; 17 | 18 | public static void main(String... args) { 19 | for (int i = 5; i < 17; i++) { 20 | System.out.println("Testing with size " + (1 << i)); 21 | test(1 << i); 22 | } 23 | } 24 | 25 | private static void test(int size) { 26 | StringBuilder sb = new StringBuilder(); 27 | for (int i = 0; i < size; i++) { 28 | sb.append(zeroHashCodes[i % zeroHashCodes.length]); 29 | } 30 | String s = sb.toString(); 31 | System.out.println("s.length() = " + s.length()); 32 | System.out.println("s.hashCode() = " + s.hashCode()); 33 | 34 | long time = System.nanoTime(); 35 | try { 36 | int total = 0; 37 | for (int i = 0; i < 10000; i++) { 38 | total += s.hashCode(); 39 | } 40 | System.out.println("total = " + total); 41 | } finally { 42 | time = System.nanoTime() - time; 43 | System.out.printf("call hashCode() 10000x = %dms%n", (time / 1000000)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/eu/javaspecialists/playground/hasher/StringDOS.java: -------------------------------------------------------------------------------- 1 | package eu.javaspecialists.playground.hasher; 2 | 3 | import java.util.*; 4 | 5 | // Java 6 get() is linear 6 | // Java 7 get() is also linear, but special case for Strings if you us -Djdk.map.althashing.threshold=512 7 | // hashes differently 8 | // Java 8+ get() is logarithmic when bucket has a lot of clashes 9 | 10 | // source code is compatible with Java 6 11 | public class StringDOS { 12 | private static final String[] zeroHashCodes = { 13 | "ARbyguv", "ARbygvW", "ARbyhVv", "ARbyhWW", "ARbzHuv", "ARbzHvW", "ARbzIVv", "ARbzIWW", 14 | "ARcZguv", "ARcZgvW", "ARcZhVv", "ARcZhWW", "ASCyguv", "ASCygvW", "ASCyhVv", "ASCyhWW", 15 | "ASCzHuv", "ASCzHvW", "ASCzIVv", "ASCzIWW", "ASDZguv", "ASDZgvW", "ASDZhVv", "ASDZhWW", 16 | }; 17 | 18 | public static void main(String... args) { 19 | for (int i = 5; i < 24; i++) { 20 | System.out.println("Testing with size " + (1 << i)); 21 | test(1 << i); 22 | } 23 | } 24 | 25 | private static void test(int size) { 26 | Map map = new HashMap(); 27 | long time = System.nanoTime(); 28 | try { 29 | for (int i = 0; i < size; i++) { 30 | StringBuilder sb = new StringBuilder(); 31 | for (int j = 1, index = 0; j <= i; j <<= 1, index++) { 32 | if ((i & j) != 0) 33 | sb.append(zeroHashCodes[index % zeroHashCodes.length]); 34 | } 35 | map.put(sb.toString(), i); 36 | } 37 | } finally { 38 | time = System.nanoTime() - time; 39 | System.out.printf("creating map took time = %dms%n", (time / 1000000)); 40 | } 41 | 42 | System.out.println("map.size() = " + map.size()); 43 | for (String s : map.keySet()) { 44 | if (s.hashCode() != 0) 45 | throw new AssertionError("hashCode() of " + s + " is not 0"); 46 | } 47 | System.out.println("All hashCode() were 0"); 48 | String notInMap = zeroHashCodes[1] + zeroHashCodes[0]; 49 | for (int repeats = 0; repeats < 10; repeats++) { 50 | testLookup(map, notInMap); 51 | } 52 | } 53 | 54 | private static void testLookup(Map map, String notInMap) { 55 | long time = System.nanoTime(); 56 | try { 57 | for (int i = 0; i < 1000 * 1000; i++) { 58 | map.get(notInMap); 59 | } 60 | } finally { 61 | time = System.nanoTime() - time; 62 | System.out.printf("time = %dms%n", (time / 1000000)); 63 | } 64 | } 65 | } 66 | --------------------------------------------------------------------------------