This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/jmh/kotlin/com/mapk/fastkfunction/singleargfastkfunction Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ open class CallObjectMethodBenchmark {
2525 .first { it.name == " companionObjectFun1" } as KFunction <Constructor1 >
2626
2727 private val argumentMap: Map <KParameter , Any ?> = mapOf (functionByMethodReference.parameters.single() to argument)
28+ private val argumentMapWithInstance: Map <KParameter , Any ?> = functionByReflection.parameters.let {
29+ mapOf (
30+ it[0 ] to objectInstance,
31+ it[1 ] to argument
32+ )
33+ }
2834
2935 private val javaMethod: Method = functionByMethodReference.javaMethod!!
3036
@@ -58,10 +64,10 @@ open class CallObjectMethodBenchmark {
5864 fun functionByMethodReferenceCallBy (): Constructor1 = functionByMethodReference.callBy(argumentMap)
5965
6066 @Benchmark
61- fun functionByReflectionCall (): Constructor1 = functionByReflection.call(argument)
67+ fun functionByReflectionCall (): Constructor1 = functionByReflection.call(objectInstance, argument)
6268
6369 @Benchmark
64- fun functionByReflectionCallBy (): Constructor1 = functionByReflection.callBy(argumentMap )
70+ fun functionByReflectionCallBy (): Constructor1 = functionByReflection.callBy(argumentMapWithInstance )
6571
6672 @Benchmark
6773 fun javaMethod (): Constructor1 = javaMethod.invoke(objectInstance, argument) as Constructor1
You can’t perform that action at this time.
0 commit comments