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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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 Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.8k
AgentCoreとHuman in the Loop
har1101
5
220
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
140
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
680
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
12
6.4k
Package Management Learnings from Homebrew
mikemcquaid
0
190
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
290
Basic Architectures
denyspoltorak
0
660
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
18
6.3k
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
0
870
Patterns of Patterns
denyspoltorak
0
1.3k
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
510
Featured
See All Featured
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
160
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
A better future with KSS
kneath
240
18k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
54
Context Engineering - Making Every Token Count
addyosmani
9
640
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Faster Mobile Websites
deanohume
310
31k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
89
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
71
Docker and Python
trallard
47
3.7k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
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 !! マネーフォワードでは 全方位採用中です! カジュアル面談もお待ちしておりま す!