Home > Software engineering >  Parsing Fluidity data from dumpsys eve
Parsing Fluidity data from dumpsys eve

Time:08-11

The below is a sample data from dumpsys eve log. I am trying to get the fluidity metrics block with the assumption that it only contains 1m, 3m and 5m metrics. But what if in future any additional Xm is introduced, is there a generic solution for it ?

Fluidity:
Sample One#0
1m: 0|0|0|0|0 total=7 dropped=0
3m: 0|0|0|0|0 total=7 dropped=0
5m: 0|0|0|0|0 total=7 dropped=0
Xm: 1|2|1|0|0 total=197 dropped=4
#1
1m: 0|0|0|0|0 total=7 dropped=0
3m: 0|0|0|0|0 total=7 dropped=0
5m: 0|0|0|0|0 total=7 dropped=0
Xm: 1|2|1|0|0 total=197 dropped=4
com.sample.app1/com.android.app1.App1#0
1m: 1|2|1|0|0 total=197 dropped=4
3m: 1|2|1|0|0 total=197 dropped=4
5m: 1|2|1|0|0 total=197 dropped=4
Xm: 1|2|1|0|0 total=197 dropped=4
Xm: 1|2|1|0|0 total=197 dropped=4
com.sample.app2.identity/com.sample.App2#0
1m: 0|0|0|1|0 total=26 dropped=1
3m: 0|0|0|1|0 total=26 dropped=1
5m: 0|0|0|1|0 total=26 dropped=1
Xm: 1|2|1|0|0 total=197 dropped=4

The regex I created only fetch the first 3 for each activity.

(.*<Sample>((.*(\n|\r|\r\n)){4}))

This provides the match for

Sample Scrim#0
1m: 0|0|0|0|0 total=7 dropped=0
3m: 0|0|0|0|0 total=7 dropped=0
5m: 0|0|0|0|0 total=7 dropped=0

I need a generic regex that include Xm lines too in future.

CodePudding user response:

(.*<Sample>((.*(\n|\r|\r\n)){4,}))

Changed to quantifier to requiring 4 or more.

The result can be checked here: https://regexr.com/

CodePudding user response:

You might account for the Xm value using an alternation:

^Sample\b.*((?:\r?\n(?:\d |X)m:.*) )

Explanation

  • ^ Start of string
  • Sample\b Match the word Sample
  • .* Match the rest of the line
  • ( Capture group 1
    • (?: Non capture group to repeat as a whole part
      • \r?\n Match a newline
      • (?:\d |X)m:.* Match either 1 digits or X and then m:
    • ) Close the non capture group and repeat 1 times to match at least 1 line
  • ) Close group 1

regex demo

  • Related