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

Commit 3162a57

Browse files
committed
高速性周りを最初に書く形で追記
1 parent df95f81 commit 3162a57

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

README.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,41 @@ val result: Sample = fastKFunction.generateBucket()
3636
.let { fastKFunction.callBy(it) }
3737
```
3838

39+
## How Fast?
40+
Calling the constructor is more than 1.2 times faster than calling `KFunction` with `call`,
41+
and more than 6 times faster than calling it with `callBy`.
42+
43+
You can get the same speed as `reflection` in `Java`.
44+
45+
| | ops/s |Ratio|
46+
|-----------------------|------------:|-----|
47+
| Java Constructor |`104267558.4`|`6.7`|
48+
| FastKFunction(call) |`102948283.4`|`6.6`|
49+
| FastKFunction(callBy) |`105609306.2`|`6.8`|
50+
| KFunction(call) | `77096714.2`|`5.0`|
51+
| KFunction(callBy) | `15519730.2`|`1` |
52+
53+
![ConstructorBenchmarkResultGraph.png](./pictures/ConstructorBenchmarkResultGraph.png)
54+
55+
*This is the score I got on a `Ryzen7 3700X` in a `Windows 10` environment, with [3b8687](https://github.com/ProjectMapK/FastKFunction/tree/3b8687da712319a49e4f58a38edbb016cc0c41b7) committed.
56+
57+
### Raw data, and other comparisons
58+
You can get full benchmark score and some other graphs [here](https://docs.google.com/spreadsheets/d/1DJhf8KX1-BAxCGor5cZdlO3626AZbKeet-rkk26XGAE/).
59+
60+
### Mechanism
61+
I have a blog post on the mechanism of fast invocation (in Japanese).
62+
63+
- [【Kotlin】KFunctionを高速に呼び出す(前編) \- Qiita](https://qiita.com/wrongwrong/items/f7b15d54956191f471d1)
64+
- [【Kotlin】KFunctionを高速に呼び出す(後編) \- Qiita](https://qiita.com/wrongwrong/items/fe75bae3911eff319e68)
65+
66+
### Benchmarking
67+
You can run the benchmark with the `./gradlew jmh`.
68+
Please note that it will take about 5 hours in total if executed with the default settings.
69+
70+
```bash
71+
./gradlew jmh
72+
```
73+
3974
## Installation
4075
`FastKFunction` is published on JitPack.
4176
You can use this library on `Maven`, `gradle` and any other build tools.
@@ -115,11 +150,3 @@ val fastKFunction: SingleArgFastKFunction<Sample> = SingleArgFastKFunction.of(::
115150

116151
val result: Sample = fastKFunction.call(1)
117152
```
118-
119-
## Benchmark
120-
You can run the benchmark with the `./gradlew jmh`.
121-
Please note that it will take about 2 hours in total if executed with the default settings.
122-
123-
```bash
124-
./gradlew jmh
125-
```

0 commit comments

Comments
 (0)