Compose Baseline Profile CI 적용

강현석·2022년 12월 11일
0

performance

목록 보기
1/3

전제조건

스크립트 작성(Github Action 기준)

1. 디바이스 초기화

- name: Clean Managed Devices
  run: ./gradlew cleanManagedDevices --unused-only
  • 에뮬레이터의 공간을 확보하기 위해 디바이스 정리

2. Baseline Profile 생성

- name: Generate Baseline Profile
  run: |
    ./gradlew :benchmark:pixel2Api31BenchmarkAndroidTest -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile -Dorg.gradle.workers.max=4
  • :benchmark:pixel2Api31BenchmarkAndroidTest
    - pixel2Api31 : devices 옵션에서 정의한 이름
  • -Pandroid.testoptions.manageddevices.emulator.gpu
    - 에뮬레이터의 gpu 설정
  • -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules
    - testInstrumentationRunner의 Rule 설정
    • @get:Rule val baselineProfileRule = BaselineProfileRule()

3. 생성된 Profile 이동

- name: Move & Rename Baseline Profiles
    run: |
      mv -f benchmark/build/outputs/managed_device_android_test_additional_output/pixel2Api31/ExampleStartupBenchmark_startup-baseline-prof.txt app/src/main/baseline-prof.txt
  • path/../ExampleStartupBenchmark_startup-baseline-prof.txt
    - ExampleStartupBenchmark은 benchmark를 수행할 클래스명
  • app/src/main/baseline-prof.txt
    - baseline-prof.txt 이름으로 이 위치로 이동

결과


1. 생각보다 Baseline Profile 생성이 꽤 오래 걸림
2. 프로덕션 배포 시 까먹지 않아서 좋음

참고

profile
볼링을 좋아하는 안드로이드 개발자

0개의 댓글