Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Jetpack Macrobenchmarkを試してみた
Search
Masayuki Suda
June 21, 2021
Programming
1
350
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
810
Android端末で実現するオンデバイスLLM 2025 続き
masayukisuda
0
9
Android端末で実現するオンデバイスLLM 2025
masayukisuda
1
450
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
2
3.2k
Kotlin Collection関数をマスター
masayukisuda
1
5.8k
MediaCodecで動画編集をしてみよう
masayukisuda
3
4.7k
Androidで動画編集アプリの技術選択
masayukisuda
1
1.3k
Other Decks in Programming
See All in Programming
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
260
CloudNative Days Winter 2025: 一週間で作る低レイヤコンテナランタイム
ternbusty
7
1.9k
Microservices Platforms: When Team Topologies Meets Microservices Patterns
cer
PRO
1
920
Herb to ReActionView: A New Foundation for the View Layer @ San Francisco Ruby Conference 2025
marcoroth
0
240
[堅牢.py #1] テストを書かない研究者に送る、最初にテストを書く実験コード入門 / Let's start your ML project by writing tests
shunk031
11
6.9k
TypeScript 5.9 で使えるようになった import defer でパフォーマンス最適化を実現する
bicstone
1
1k
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
120
Reactive Thinking with Signals and the new Resource API
manfredsteyer
PRO
0
160
社内オペレーション改善のためのTypeScript / TSKaigi Hokuriku 2025
dachi023
1
480
AIと協働し、イベントソーシングとアクターモデルで作る後悔しないアーキテクチャ Regret-Free Architecture with AI, Event Sourcing, and Actors
tomohisa
5
18k
『実践MLOps』から学ぶ DevOps for ML
nsakki55
2
550
Building AI Agents with TypeScript #TSKaigiHokuriku
izumin5210
6
1.2k
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Producing Creativity
orderedlist
PRO
348
40k
Faster Mobile Websites
deanohume
310
31k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
How to Think Like a Performance Engineer
csswizardry
28
2.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Bash Introduction
62gerente
615
210k
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 !! マネーフォワードでは 全方位採用中です! カジュアル面談もお待ちしておりま す!