Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit 2779af0

Browse files
committed
インスタンス周りで実行が失敗していた問題への対応
1 parent b9e3f3d commit 2779af0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/jmh/kotlin/com/mapk/fastkfunction/singleargfastkfunction/CallObjectMethodBenchmark.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)