Created
November 19, 2024 15:23
-
-
Save qwwdfsad/b13d2035f13279efb289c7d19b64b6e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@State(Scope.Thread) | |
open class ArrayAllocationBenchmark { | |
var y: Int = 42 | |
@Benchmark | |
@CompilerControl(CompilerControl.Mode.DONT_INLINE) | |
fun arrayOf(): Any { | |
return arrayOf<Any>(java.lang.Integer.valueOf(y), java.lang.Integer.valueOf(y), java.lang.Integer.valueOf(y)) | |
} | |
@Benchmark | |
@CompilerControl(CompilerControl.Mode.DONT_INLINE) | |
fun arrayOfLocals(): Any { | |
val x1 = java.lang.Integer.valueOf(y) | |
val x2 = java.lang.Integer.valueOf(y) | |
val x3 = java.lang.Integer.valueOf(y) | |
return arrayOf<Any>(x1, x2, x3) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment