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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yuta Tomiyama
September 26, 2020
Programming
130
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
どのKotlinが一番速い?
Zli × excite 合同LT にて発表
Yuta Tomiyama
September 26, 2020
Transcript
20 slides
どの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
More Decks by Yuta Tomiyama
See All by Yuta Tomiyama
ビルドプロセスをデバッグしよう!
yt8492
2
530
モバイルアプリ開発を始めよう!
yt8492
0
150
Git勉強会
yt8492
0
250
なんでもやってみる勇気
yt8492
0
150
Android Autoが思ったよりしんどい話
yt8492
0
260
apollo-kotlinにcontributeした話
yt8492
0
210
DMM TVのSDカードダウンロード機能を実装した話
yt8492
1
1.1k
今だからこそ知りたいKotlin Multiplatform
yt8492
0
370
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
AIコーディング時代のKotest ユニットテストから APIレベルの仕様固定化テストへ
ooga04
0
340
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
270
Jujutsu で毎日のバージョン管理に「安心」と「直感性」を
oukayuka
0
110
Compiling Your Language to WasmGC & Friends
tanishiking
0
200
はじめてのKubernetesコントリビューション
nasa9084
0
330
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
200
Claude Codeのおかげでやりたいことがやれるようになったんだよォー!
sms_tech
0
190
読みやすい!と評判(?)の発表の準備にかける私のこだわり
shoheimitani
0
170
protojson における文字化けの扱い
kazuki1023
0
470
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
450
ruby/uri meets WHATWG
jinroq
0
150
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
1
250
The Art of Programming - Codeland 2020
erikaheidi
57
15k
How Software Deployment tools have changed in the past 20 years
geshan
3
35k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
550
Accessibility Awareness
sabderemane
1
310
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
580
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.7k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
2
560
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
The World Runs on Bad Software
bkeepers
PRO
72
12k