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 {
25
25
.first { it.name == " companionObjectFun1" } as KFunction <Constructor1 >
26
26
27
27
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
+ }
28
34
29
35
private val javaMethod: Method = functionByMethodReference.javaMethod!!
30
36
@@ -58,10 +64,10 @@ open class CallObjectMethodBenchmark {
58
64
fun functionByMethodReferenceCallBy (): Constructor1 = functionByMethodReference.callBy(argumentMap)
59
65
60
66
@Benchmark
61
- fun functionByReflectionCall (): Constructor1 = functionByReflection.call(argument)
67
+ fun functionByReflectionCall (): Constructor1 = functionByReflection.call(objectInstance, argument)
62
68
63
69
@Benchmark
64
- fun functionByReflectionCallBy (): Constructor1 = functionByReflection.callBy(argumentMap )
70
+ fun functionByReflectionCallBy (): Constructor1 = functionByReflection.callBy(argumentMapWithInstance )
65
71
66
72
@Benchmark
67
73
fun javaMethod (): Constructor1 = javaMethod.invoke(objectInstance, argument) as Constructor1
You can’t perform that action at this time.
0 commit comments