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
110
どのKotlinが一番速い?
Zli × excite 合同LT にて発表
Yuta Tomiyama
September 26, 2020
Tweet
Share
More Decks by Yuta Tomiyama
See All by Yuta Tomiyama
ビルドプロセスをデバッグしよう!
yt8492
1
370
モバイルアプリ開発を始めよう!
yt8492
0
82
Git勉強会
yt8492
0
180
なんでもやってみる勇気
yt8492
0
110
Android Autoが思ったよりしんどい話
yt8492
0
220
apollo-kotlinにcontributeした話
yt8492
0
160
DMM TVのSDカードダウンロード機能を実装した話
yt8492
1
900
今だからこそ知りたいKotlin Multiplatform
yt8492
0
310
State management and API calls in Jetpack Compose: Learning Apollo + Jetpack Compose through React Hooks
yt8492
0
1.3k
Other Decks in Programming
See All in Programming
AtCoder Conference 2025
shindannin
0
880
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
2k
AIエージェントの設計で注意するべきポイント6選
har1101
6
2.9k
大規模Cloud Native環境におけるFalcoの運用
owlinux1000
0
240
SQL Server 2025 LT
odashinsuke
0
120
Navigating Dependency Injection with Metro
l2hyunwoo
1
200
CSC307 Lecture 03
javiergs
PRO
1
460
実はマルチモーダルだった。ブラウザの組み込みAI🧠でWebの未来を感じてみよう #jsfes #gemini
n0bisuke2
3
1.4k
Grafana:建立系統全知視角的捷徑
blueswen
0
270
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
920
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
280
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
7
4.2k
Featured
See All Featured
Digital Ethics as a Driver of Design Innovation
axbom
PRO
0
140
Fireside Chat
paigeccino
41
3.8k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
130
Applied NLP in the Age of Generative AI
inesmontani
PRO
3
2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Rails Girls Zürich Keynote
gr2m
95
14k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
160
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
250
Information Architects: The Missing Link in Design Systems
soysaucechin
0
730
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
130
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