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
Jetpack Macrobenchmarkを試してみた
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Masayuki Suda
June 21, 2021
Programming
1
360
Jetpack Macrobenchmarkを試してみた
2021/06/21 (Mon)
Money Forward Tech Driveで話した内容です。
Masayuki Suda
June 21, 2021
Tweet
Share
More Decks by Masayuki Suda
See All by Masayuki Suda
Rewind & Replay: Kotlin 2.2が変えるCoroutine デバッグ最前線
masayukisuda
1
1.6k
Android端末で実現するオンデバイスLLM 2025 続き
masayukisuda
0
27
Android端末で実現するオンデバイスLLM 2025
masayukisuda
2
560
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
2
3.5k
Kotlin Collection関数をマスター
masayukisuda
1
6k
MediaCodecで動画編集をしてみよう
masayukisuda
3
4.7k
Androidで動画編集アプリの技術選択
masayukisuda
1
1.4k
Other Decks in Programming
See All in Programming
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.8k
AIエージェントの設計で注意するべきポイント6選
har1101
7
3.4k
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
440
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
960
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
140
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
540
Patterns of Patterns
denyspoltorak
0
1.3k
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
590
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
410
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
110
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
53
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
4 Signs Your Business is Dying
shpigford
187
22k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
56
50k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
160
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
280
WCS-LA-2024
lcolladotor
0
440
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
55
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
47
Transcript
Jetpack Macrobenchmarkを試してみた 2021/06/21 (Mon) Money Forward Tech Drive @daasuu
もくじ • Jetpack Macrobenchmarkとは • 実装方法 • カスタマイズ • 参考資料
Jetpack Macrobenchmarkとは
Jetpack Macrobenchmarkとは Android Studioでアプリのパフォーマンスがsystraceレベルでわかるツール
Jetpack Macrobenchmarkとは • 起動時等に何にどれくらい時間がかかっているか、スクロール時に何にどれくらい時間がか かっているかを、見える化してくれます
Jetpack Macrobenchmarkとは • 個別に選択して、中身の詳細を見ることもできます
None
Jetpack Macrobenchmarkとは 何が嬉しいの? • Firebase等のAnalyticsのパフォーマンスは複数端末での統計値等はわかるが、開発 者の手元でsystraceレベルで計測できる • 既存のJetpack Performanceライブラリーでは、測定でよくあるミスを防ぐのに役立ち ますが、アプリ起動時の詳細なパフォーマンス測定や、60fpsを阻むジャンクの測定は
できない • 結果をjsonで吐き出してくれるので、CIとの組み込みも行いやすい ◦ emulatorでは動かないので、Firebase Testlab等の実機テストのみ
実装方法
実行環境
Macrobenchmark 実装方法 • 新しいモジュールを追加する • マクロベンチマークを作成する
Macrobenchmark 実装方法 新しいモジュールを追加する • Android Libraryでモジュールをきる ◦ [Minimum SDK] を [API
29: Android 10.0 (Q)] に設定
Macrobenchmark 実装方法 新しいモジュールを追加する • 切ったモジュールのGradle ファイルを変更する ◦ プラグインを com.android.library から com.android.test
に変更 ◦ testImplementation または androidTestImplementation という名前のすべての 依存関係を implementation に変更 ◦ Macrobenchmark を実行する記述を追加
Macrobenchmark 実装方法 新しいモジュールを追加する • プラグインを com.android.library から com.android.test に変更
Macrobenchmark 実装方法 新しいモジュールを追加する • testImplementation または androidTestImplementation という名前のすべての依存 関係を implementation に変更
Macrobenchmark 実装方法 新しいモジュールを追加する • Macrobenchmark を実行する記述を追加 ◦ android のblockに下記を追加します • android
{} ブロックの後、dependencies {} ブロックの前に、以下の行を追加しま す。
Macrobenchmark 実装方法 • マクロベンチマークを作成する
Macrobenchmark 実装方法 マクロベンチマークを作成する • JUnit4で動くclassをセット
Macrobenchmark 実装方法 マクロベンチマークを作成する • MacrobenchmarkRuleをセットします
• measureRepeatedメソッドを追加 ◦ ブロックパスを数回実行してパフォーマンステストを実行します。 Macrobenchmark 実装方法 マクロベンチマークを作成する
Macrobenchmark 実装方法 マクロベンチマークを作成する • App起動の挙動を追加 ◦ ホームボタンを押してデバイスをリセット後、アプリを起動
• 対象Appのパッケージを追加 Macrobenchmark 実装方法 マクロベンチマークを作成する
• テスト対象となる指標を設定 Macrobenchmark 実装方法 マクロベンチマークを作成する
Macrobenchmark 実装方法 テストとなる指標の種類 • StartupTimingMetric ◦ アプリの起動のパフォーマンスを測定 • Frame Timing Metric
◦ スクロールやアニメーションフレームのパフォーマンスを測定
• アプリのコンパイル方法を指定 Macrobenchmark 実装方法 マクロベンチマークを作成する
Macrobenchmark 実装方法 コンパイル方法の種類 • None ◦ アプリが全くコンパイルされていない場合 • SpeedProfile ◦ 部分的にコンパイルされている場合
• Speed ◦ 完全にコンパイルされている場合
Macrobenchmark 実装方法 マクロベンチマークを作成する • アプリの起動の種類を指定
Macrobenchmark 実装方法 アプリの起動の種類 • Hot ◦ 既にオンメモリにあるものを起動。 ▪ Activity onResumeのみ実行 •
Warn ◦ 既存プロセス内でアクティビティを構築して起動 ▪ Activity onStart onResume が実行 • Cold ◦ 実行されていないプロセスから起動 ▪ Process Init 〜 Activity onResumeまで実行
Macrobenchmark 実装方法 マクロベンチマークを作成する • テストの実行回数を指定
Macrobenchmark 実装方法 実行結果 • テストを実行!
Macrobenchmark 実装方法 実行結果
カスタマイズについて
カスタマイズについて • tracing-ktxを使用する ◦ トレースメソッドでラップするだけでどんな時間でも計ることができます
カスタマイズについて • tracing-ktxをdependenciesに追加 • testするメソッドを用意 • ActivityのonCreate〜onResumeの間でhogePrint()をcall ◦ 起動テストに無理やり組み込むので今回は上記のやり方で実施
カスタマイズについて
参考資料
参考資料 • Macrobenchmark を使用したジャンクとスタートアップの測定 - Youtube ◦ https://youtu.be/0adLO2VRJtc • Jetpack
Macrobenchmark でユースケースのベンチマークを行う ◦ https://developer.android.com/studio/profile/macrobenchmark • android Macrobenchmark 公式サンプル - github ◦ スクロールのサンプルも記載されてます ◦ https://github.com/android/performance-samples/tree/main/Macrobenchm arkSample
We’re hiring !! マネーフォワードでは 全方位採用中です! カジュアル面談もお待ちしておりま す!