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
370
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.7k
Android端末で実現するオンデバイスLLM 2025 続き
masayukisuda
0
29
Android端末で実現するオンデバイスLLM 2025
masayukisuda
2
600
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
2
3.6k
Kotlin Collection関数をマスター
masayukisuda
1
6k
MediaCodecで動画編集をしてみよう
masayukisuda
3
4.7k
Androidで動画編集アプリの技術選択
masayukisuda
1
1.4k
Other Decks in Programming
See All in Programming
オブザーバビリティ駆動開発って実際どうなの?
yohfee
1
350
Head of Engineeringが現場で回した生産性向上施策 2025→2026
gessy0129
PRO
0
190
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
310
ぼくの開発環境2026
yuzneri
1
290
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
140
Geminiの機能を調べ尽くしてみた
naruyoshimi
0
170
今更考える「単一責任原則」 / Thinking about the Single Responsibility Principle
tooppoo
2
910
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
170
株式会社 Sun terras カンパニーデック
sunterras
0
1.8k
あなたはユーザーではない #PdENight
kajitack
4
270
PJのドキュメントを全部Git管理にしたら、一番喜んだのはAIだった
nanaism
0
210
CSC307 Lecture 07
javiergs
PRO
1
560
Featured
See All Featured
Building an army of robots
kneath
306
46k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3k
Six Lessons from altMBA
skipperchong
29
4.2k
Building AI with AI
inesmontani
PRO
1
740
Paper Plane (Part 1)
katiecoart
PRO
0
4.8k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Between Models and Reality
mayunak
1
210
Odyssey Design
rkendrick25
PRO
2
520
Technical Leadership for Architectural Decision Making
baasie
2
260
Building the Perfect Custom Keyboard
takai
2
700
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
450
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
180
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 !! マネーフォワードでは 全方位採用中です! カジュアル面談もお待ちしておりま す!