Skip to content

Commit

Permalink
fix: fps bugs and perf data zero, see https://sonic-cloud.wiki/d/2527,
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Feb 4, 2023
1 parent 97ebec9 commit 4acbbc1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/perfmonUtil/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func GetPidOnPackageName(client *adb.Device, appName string) (pid string, err er
log.Panic(err)
}

reg := regexp.MustCompile(fmt.Sprintf("ACTIVITY\\s%s.*", appName))
reg := regexp.MustCompile(fmt.Sprintf("ACTIVITY\\s%s.*\\d", appName))

regResult := reg.FindString(string(data))

Expand Down Expand Up @@ -380,8 +380,10 @@ func GetProcessInfo(client *adb.Device, pid string, packageName string, perfOpti
processInfo = &entity.ProcessInfo{}
}
var threads int
if threads, err = strconv.Atoi(status.Threads); err != nil {
processInfo.Error = append(processInfo.Error, err.Error())
if len(status.Threads) > 0 {
if threads, err = strconv.Atoi(status.Threads); err != nil {
processInfo.Error = append(processInfo.Error, err.Error())
}
}
processInfo.Threads = &threads
}
Expand Down Expand Up @@ -490,9 +492,9 @@ func getProcessFPSBySurfaceFlinger(client *adb.Device, pkg string) (result int,
activity := ""

scanner := bufio.NewScanner(lines)
reg := regexp.MustCompile("\\[.*#0|\\(.*\\)")
for scanner.Scan() {
line := scanner.Text()
reg := regexp.MustCompile("\\[.*#0")

activity = reg.FindString(line)

Expand All @@ -504,8 +506,8 @@ func getProcessFPSBySurfaceFlinger(client *adb.Device, pkg string) (result int,
if activity == "" {
return 0, errors.New(fmt.Sprintf("could not find app %s activity", pkg))
}
//var r = strings.NewReplacer("[", "", "")
activity = strings.Replace(activity, "[", "", 1)
r := strings.NewReplacer("[", "", "(", "", ")", "")
activity = r.Replace(activity)

lines, err = client.OpenShell(
fmt.Sprintf("dumpsys SurfaceFlinger --latency '%s'", activity))
Expand Down

0 comments on commit 4acbbc1

Please sign in to comment.