Skip to content

Instantly share code, notes, and snippets.

@qwwdfsad
Created November 19, 2024 15:23
Show Gist options
  • Save qwwdfsad/b13d2035f13279efb289c7d19b64b6e1 to your computer and use it in GitHub Desktop.
Save qwwdfsad/b13d2035f13279efb289c7d19b64b6e1 to your computer and use it in GitHub Desktop.
@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