Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e44631da authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "startop: Update parse_metrics to parse #ReportFullyDrawn"

parents 1115b409 2f54a688
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
#!/bin/bash
#
# Copyright 2019, The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# 05-06 14:51:17.688 29691 29897 I CAM_Timing: CameraActivity: START -> ACTIVITY_FIRST_PREVIEW_FRAME_RECEIVED: 385ms
pattern="CAM_Timing: CameraActivity: START -> ACTIVITY_FIRST_PREVIEW_FRAME_RECEIVED:"
re_pattern='.*ACTIVITY_FIRST_PREVIEW_FRAME_RECEIVED: \([[:digit:]]\+\)ms'
parse_metric_from_logcat "ACTIVITY_FIRST_PREVIEW_FRAME_RECEIVED_ms" "$pattern" "$re_pattern"

# 05-06 14:51:17.724 29691 29691 I CAM_Timing: CameraActivity: START -> ACTIVITY_FIRST_PREVIEW_FRAME_RENDERED: 421ms
pattern="CAM_Timing: CameraActivity: START -> ACTIVITY_FIRST_PREVIEW_FRAME_RENDERED:"
re_pattern='.*ACTIVITY_FIRST_PREVIEW_FRAME_RENDERED: \([[:digit:]]\+\)ms'
parse_metric_from_logcat "ACTIVITY_FIRST_PREVIEW_FRAME_RENDERED_ms" "$pattern" "$re_pattern"
+27 −3
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ source "$DIR/lib/common"

package=""
activity=""
timeout=10
timeout=5
simulate="n"
parse_arguments() {
  while [[ $# -gt 0 ]]; do
@@ -123,6 +123,9 @@ parse_metric_from_logcat() {
  local pattern="$2"
  local re_pattern="$3"
  local retcode
  local result
  local sec
  local ms

  # parse logcat for 'Displayed...' and that other one...

@@ -137,14 +140,28 @@ parse_metric_from_logcat() {
    return 0
  fi

  logcat_extract_pattern "$timeout" "$timestamp" "$pattern" "$re_pattern"
  result="$(logcat_extract_pattern "$timeout" "$timestamp" "$pattern" "$re_pattern")"
  retcode=$?

  if [[ $retcode -ne 0 ]]; then
    # Timed out before finding the pattern. Could also mean the pattern is wrong.
    echo "Parse $re_pattern from logcat TIMED OUT after $timeout seconds." >&2
    echo "-$?"
    return $retcode
  fi

  # "10s123ms" -> "10s123"
  result=${result/ms/}
  if [[ $result =~ s ]]; then
    ms=${result/*s/}
    sec=${result/s*/}
  else
    sec=0
    ms=$result
  fi
  ((result=sec*1000+ms))

  echo "$result"
  return $retcode
}

@@ -169,10 +186,17 @@ echo "TotalTime_ms=$total_time"

# 05-06 14:34:08.854 29460 29481 I ActivityTaskManager: Displayed com.google.android.dialer/.extensions.GoogleDialtactsActivity: +361ms
pattern="ActivityTaskManager: Displayed ${package}"
re_pattern='.*Displayed[[:blank:]]\+'"${package}"'[/][^[:blank:]]\+[[:blank:]]+\([[:digit:]]\+\).*'
re_pattern='.*Displayed[[:blank:]]\+'"${package}"'[/][^[:blank:]]\+[[:blank:]]+\([[:digit:]]\+ms\|[[:digit:]]\+s[[:digit:]]\+ms\).*'

parse_metric_from_logcat "Displayed_ms" "$pattern" "$re_pattern"

# 01-16 17:31:44.550 11172 11204 I ActivityTaskManager: Fully drawn com.google.android.GoogleCamera/com.android.camera.CameraLauncher: +10s897ms
pattern="ActivityTaskManager: Fully drawn ${package}"
#re_pattern='.*Fully drawn[[:blank:]]\+'"${package}"'[/][^[:blank:]]\+[[:blank:]]+\([[:digit:]]\+\).*'
re_pattern='.*Fully drawn[[:blank:]]\+'"${package}"'[/][^[:blank:]]\+[[:blank:]]+\([[:digit:]]\+ms\|[[:digit:]]\+s[[:digit:]]\+ms\).*'

parse_metric_from_logcat "Fully_drawn_ms" "$pattern" "$re_pattern"

# also call into package-specific scripts if there are additional metrics
if [[ -x "$DIR/metrics/$package" ]]; then
  source "$DIR/metrics/$package" "$timestamp"