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
580
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
Oxlintはいいぞ
yug1224
5
1.4k
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
210
MUSUBIXとは
nahisaho
0
140
CSC307 Lecture 08
javiergs
PRO
0
670
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
310
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
130
ぼくの開発環境2026
yuzneri
0
240
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
120
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
180
並行開発のためのコードレビュー
miyukiw
0
320
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
180
Featured
See All Featured
Designing for Timeless Needs
cassininazir
0
130
Writing Fast Ruby
sferik
630
62k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Google's AI Overviews - The New Search
badams
0
910
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
420
The SEO identity crisis: Don't let AI make you average
varn
0
290
Code Review Best Practice
trishagee
74
20k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.6k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
Done Done
chrislema
186
16k
We Have a Design System, Now What?
morganepeng
54
8k
Producing Creativity
orderedlist
PRO
348
40k
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 !! マネーフォワードでは 全方位採用中です! カジュアル面談もお待ちしておりま す!