Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
どのKotlinが一番速い?
Search
Yuta Tomiyama
September 26, 2020
Programming
1
99
どのKotlinが一番速い?
Zli × excite 合同LT にて発表
Yuta Tomiyama
September 26, 2020
Tweet
Share
More Decks by Yuta Tomiyama
See All by Yuta Tomiyama
モバイルアプリ開発を始めよう!
yt8492
0
31
Git勉強会
yt8492
0
88
なんでもやってみる勇気
yt8492
0
74
Android Autoが思ったよりしんどい話
yt8492
0
190
apollo-kotlinにcontributeした話
yt8492
0
120
DMM TVのSDカードダウンロード機能を実装した話
yt8492
1
820
今だからこそ知りたいKotlin Multiplatform
yt8492
0
280
State management and API calls in Jetpack Compose: Learning Apollo + Jetpack Compose through React Hooks
yt8492
0
1.2k
サーバーフレームワークの仕組みが気になったので車輪の再発明をしてみた
yt8492
0
190
Other Decks in Programming
See All in Programming
AWS Summit Hong Kong 2025: Reinventing Programming - How AI Transforms Our Enterprise Coding Approach
dwchiang
0
150
データと事例で振り返るDevin導入の"リアル" / The Realities of Devin Reflected in Data and Case Studies
rkaga
3
2.9k
バイラテラルアップサンプリング
fadis
3
640
鯛変だったRubyKaigi 2025 ── それでも楽しかった!
pndcat
0
100
SwiftDataのカスタムデータストアを試してみた
1mash0
0
150
JAWS DAYS 2025 re_Cheers: WEB
komakichi
0
130
MySQL初心者が311個のカラムにNot NULL制約を追加していってALTER TABLEについて学んだ話
hatsu38
2
150
カウシェで Four Keys の改善を試みた理由
ike002jp
1
140
「MCPを使ってる人」が より詳しくなるための解説
yamaguchidesu
0
260
Digging into the Matrix: Practicing Code Archaeology
arthurdoler
PRO
0
120
エンジニア向けCursor勉強会 @ SmartHR
yukisnow1823
3
13k
Building an Application with TDD, DDD and Hexagonal Architecture - Isn't it a bit too much?
mufrid
0
120
Featured
See All Featured
Faster Mobile Websites
deanohume
307
31k
Thoughts on Productivity
jonyablonski
69
4.6k
Six Lessons from altMBA
skipperchong
28
3.8k
Visualization
eitanlees
146
16k
Making the Leap to Tech Lead
cromwellryan
133
9.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
24
2.8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
34
2.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.2k
The Language of Interfaces
destraynor
158
25k
Transcript
どのKotlinが一番速い? 2020/09/26 Zli × excite 合同LT
自己紹介 HN: マヤミト 本名: 富山雄太 会津大学26期 (学部3年) Zli 現代表 GitHub:
https://github.com/yt8492 趣味: なんでもKotlinで作ること yt8492.com Twitter: yt8492
前提知識: Kotlinについて - Androidアプリ開発などに主に使われているJVM言語 - Kotlin/JSはKotlinをJSにトランスパイルする - Kotlin/NativeはKotlinをネイティブバイナリにコンパイルできる 011011 001010
101110 110001
ある日のぼく 「Kotlinたのし〜〜〜〜〜!!!!!!」 「Kotlin/JSたのし〜〜〜〜〜!!!!!!」 「Kotlin/Nativeたのし〜〜〜〜〜!!!!!!」 「どのKotlinが一番速いんだ……?」
検証方法 1. Kotlin/MPPでプラットフォームに依存しないテスト用コードを書く 2. ビルドする a. 実行可能なjarファイルを生成する b. nodeで実行可能なjsファイルを生成する c.
MacOSネイティブで実行可能なバイナリファイルを生成する 3. timeコマンドで計測する
環境 - MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)
- macOS Catalina 10.15.6 - CPU 2.3GHz クアッドコアIntel Core i7 - メモリ 32GB 3733MHz - OpenJDK 1.8.0_265 - node 12.18.3
テスト用コード ランダムに生成した配列をマージソートするだけのプログラム
各プラットフォームから参照する commonモジュールに置いたテスト用コードを各プラットフォー ムのモジュールから参照する プラットフォームごとにmain関数を用意し、そこからテスト用の 関数を呼び出す
JVM向けにビルド - Gradleのapplication pluginとshadow jar pluginの設定をjvm/build.gradle.ktsに 記述 - GradleのshadowJarタスクを実行し実行可能なjarファイルを生成 ./gradlew
:jvm:shadowJar - jvm/build/libs以下に生成される
Node.js向けにビルド - Kotlin/JSのbrowser向けの設定をjs/build.gradle.ktsに記述 - webpack-node-externalsの依存を追加し、node向けのビルドの設定を記述 - GradleのbrowserProductionWebpackタスクを実行しjsファイルを生成 ./gradlew :js:browserProductionWebpack -
js/build/distributions以下に生成される
MacOSネイティブ向けにビルド - Kotlin/NativeのMacOS向けの設定をnative/build.gradle.ktsに記述 - GradleのmacosMainBinariesタスクを実行しバイナリファイルを生成 ./gradlew :native:macosMainBinaries - native/build/bin/macos/releaseExecutable以下に生成される
それぞれの実行結果
timeコマンドを使って測定 - zshのtimeコマンドを使い、実行時間を測定する - それぞれ10回ずつ実行し、平均値を見る
予想 - JVMのほうがNode.jsより早そう - バイナリになるKotlin/Nativeは結構速いのでは?
Kotlin/JVM 測定結果 user: 1.229s system: 0.18s total: 1.181s
Kotlin/JS 測定結果 user: 1.683s system: 0.103s total: 1.716s
Kotlin/Native 測定結果 user: 2.060s system: 0.068s total: 2.140s
おまけ: GraalVM native-image jarファイルをnative-imageに 一番速かったが今回の趣旨からは若干離れる気がしたので割愛
実験結果 - Kotlin/JVM < Kotlin/JS < Kotlin/Native - Kotlin/Nativeはtotalで見るとKotlin/JVMの倍近く実行時間がかかったが、system 時間は一番速かった
- やはりJVMは速い
今回のリポジトリ yt8492/SpeedTest https://github.com/yt8492/SpeedTest