Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
どのKotlinが一番速い?
Search
Yuta Tomiyama
September 26, 2020
Programming
120
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
どのKotlinが一番速い?
Zli × excite 合同LT にて発表
Yuta Tomiyama
September 26, 2020
More Decks by Yuta Tomiyama
See All by Yuta Tomiyama
ビルドプロセスをデバッグしよう!
yt8492
2
520
モバイルアプリ開発を始めよう!
yt8492
0
130
Git勉強会
yt8492
0
240
なんでもやってみる勇気
yt8492
0
140
Android Autoが思ったよりしんどい話
yt8492
0
260
apollo-kotlinにcontributeした話
yt8492
0
200
DMM TVのSDカードダウンロード機能を実装した話
yt8492
1
1k
今だからこそ知りたいKotlin Multiplatform
yt8492
0
360
State management and API calls in Jetpack Compose: Learning Apollo + Jetpack Compose through React Hooks
yt8492
0
1.4k
Other Decks in Programming
See All in Programming
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
130
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
330
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
410
Groovy as a human and AI friendly programming language
paulk
0
110
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
930
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
2
110
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
200
Domain-Driven Transformation
hschwentner
2
2.3k
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
160
Simple Storage Service(S3) is not simple
iwatsukayura
0
320
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.7k
sbt 2.0: takeoff
eed3si9n
0
170
Featured
See All Featured
The SEO identity crisis: Don't let AI make you average
varn
0
590
Evolving SEO for Evolving Search Engines
ryanjones
0
330
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
880
Navigating Team Friction
lara
192
16k
Automating Front-end Workflow
addyosmani
1370
210k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
860
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
570
Prompt Engineering for Job Search
mfonobong
0
530
Between Models and Reality
mayunak
4
500
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