当前位置:网站首页>xts performance auto fix script
xts performance auto fix script
2022-07-25 01:43:00 【VinterYoung】
xts performance auto fix script
dir
|–Python310
|–source
| |-CtsMediafile
| |-Ctstest.apk
|-xts.bat
|-capture_log.bat
|-0.disturb_xml_range.py
|-1.pick_log_info.py
|-2.hanle_log_info.py
|-3.modify_xml_range.py
anlysis_log.py
xts.bat:
title media_codecs_performance by Yangwen
REM use UTF-8
chcp 65001
@echo " important !!!! "
@echo " Please use userdebug edition , Unlock and execute "
@echo " Open developer mode , In the developer options ,"
@echo "1. Open the lock screen without using ,2. Charging without sleep ,3.USB debugging , Default USB To configure MTP( Media file transfer ),4. Disable permission monitoring "
@echo " Set static wallpaper "
set PATH=Python310;tools;%PATH%;
@echo.
@echo.
@echo.
@echo " Please try to use the latest test suite CtsMediaTestCases.apk&CtsVideoTestCases.apk And media packages source Default file "
@echo " Any key continues "
@echo "please replace the default CtsMediaTestCases.apk&CtsVideoTestCases.apk&media file with latest xts test suit"
@echo "any key go on"
@pause >nul
@echo "installing Cts apk"
@echo off
adb install -r -t -d source\CtsMediaTestCases.apk
adb install -r -t -d source\CtsVideoTestCases.apk
@echo on
@echo " Set up -> application -> Application management ->android.media.cts (android.video.cts)-> Rights management : Allow all permissions "
@echo off
adb shell rm -rf /sdcard/test
adb shell mkdir -p /sdcard/test
REM adb push source\CtsVideoTestCases-1.2 /sdcard/test/
adb push source\CtsVideoTestCases-1.3 /sdcard/test/
adb push source\CtsMediaTestCases-1.4 /sdcard/test/
@echo on
@echo.
@echo " Set up xts After the permission of is completed, press any key to continue "
@pause >nul
@echo " The environment is ready , Start automatic test after automatic restart "
timeout /T 10
adb reboot
echo wait adb connect ...
adb wait-for-device
timeout /T 60
mkdir debug
adb pull /vendor/etc/media_codecs_performance.xml debug
copy debug\media_codecs_performance.xml debug\media_codecs_performance_origin.xml
copy debug\media_codecs_performance_origin.xml debug\media_codecs_performance_disturb.xml
@echo on
@echo.
@echo "replacing xml... reboot later "
python 0.disturb_xml_range.py
@echo off
adb root && adb remount &&adb shell setenforce 0 && adb shell umount -lf /vendor && adb remount && adb shell "mount -o rw,remount /vendor"
adb push debug\media_codecs_performance_disturb.xml /vendor/etc/media_codecs_performance.xml
adb pull /vendor/etc/media_codecs_performance.xml debug
timeout /T 10
adb reboot
@echo on
@echo.
@echo wait adb connect ...
adb wait-for-device
timeout /T 60
@echo off
start cmd /c "call capture_log.bat"
adb shell am instrument -e class android.media.cts.VideoDecoderPerfTest -w android.media.cts/androidx.test.runner.AndroidJUnitRunner
adb shell am instrument -e class android.video.cts.VideoEncoderDecoderTest -w android.video.cts/androidx.test.runner.AndroidJUnitRunner
timeout /T 5
@echo on
@echo.
@echo "xts performance done"
@echo "analyzing xts log and wait to modify xml"
@echo off
taskkill /f /t /FI "WINDOWTITLE eq Administrators : xts_capture_log" /IM cmd.exe
python 1.pick_log_info.py
python 2.handle_log_info.py
python 3.modify_xml_range.py
@echo on
@echo.
@echo "modify xml done,to see modify xml"
pause
capture_log.bat
title xts_capture_log
REM use UTF-8
chcp 65001
set PATH=Python310;tools;%PATH%;
@echo on
@echo "capturing logcat. do not close the window....."
adb logcat -c && adb logcat -G 32M && adb logcat > debug\xts_perf_logcat.txt
0.disturb_xml_range.py
#!/usr/bin/env python
#coding=utf-8
import os
import sys
import re
originfile=open('debug/media_codecs_performance_origin.xml','r+',encoding='utf-8',errors='ignore')
distubfile=open('debug/media_codecs_performance_disturb.xml','w+',encoding='utf-8',errors='ignore')
cleanfile=open('debug/media_codecs_performance_clean.xml','w+',encoding='utf-8',errors='ignore')
srcstring='range=".*"'
dststring='range="1-2"'
try:
string=originfile.read()
x=re.sub(r'[^\x00-\x7F]+','', string) #remove non-ascii
patten_title='^\<\?xml version.*?\<MediaCodecs\>'
matchObj = re.search(patten_title, x, re.S)
title="error"
if matchObj:
title=matchObj.group()
#print(title)
else:
print("no match")
x=re.sub(r'<!--.*?-->', ' ', x, flags=re.S) #remove comment code
x=re.sub(r' +\n', '\n', x) #remove white space and enter
x=re.sub(r'\t+\n', '\n', x) #remove tab and enter
while re.search(r'\n\n', x, re.S):
x=re.sub(r'\n\n', '\n', x, flags=re.S) #remove multi empty line
y=x
# replace xts performance range
x=re.sub(srcstring,dststring,x)
x=re.sub(patten_title,title, x, flags=re.S) #add title
distubfile.write(x)
y=re.sub(patten_title,title, y, flags=re.S) #add title
cleanfile.write(y)
finally:
distubfile.close()
originfile.close()
1.pick_log_info.py
#!/usr/bin/env python
#coding=utf-8
import os
import sys
import re
originfile=open('debug/xts_perf_logcat.txt','r+',encoding='utf-8',errors='ignore')
pickfile=open('debug/pick_log_info.txt','w+',encoding='utf-8',errors='ignore')
pattern=r'TestRunner: failed|TestRunner.*?Expected achievable frame rates|TestRunner: Measured frame rate'
for line in originfile.readlines():
x=re.sub(r'[^\x00-\x7F]+','', line) #remove non-ascii
matchObj = re.search(pattern, x)
if matchObj:
x=re.sub(r'.*?TestRunner: failed:','testcase',x)
x=re.sub(r'\(.*?\)','',x) #remove (android.media.cts.VideoDecoderPerfTest)
x=re.sub(r'.*?Expected achievable frame rates for','codecinfo',x)
x=re.sub(r'.*?Measured frame rate: ','measured ',x)
x=re.sub(r'video\/.*? ','',x)
x=re.sub(r',|\[|\]\.','',x) #remove ',[]'
x=re.sub(r'\:.*','',x) #remove config rate '[]'
pickfile.write(x)
pickfile.close()
originfile.close()
2.hanle_log_info.py:
#!/usr/bin/env python
#coding=utf-8
import os
import sys
import re
coefficient = 0.9
infofile=open('debug/pick_log_info.txt','r+',encoding='utf-8',errors='ignore')
calcfile=open('debug/pick_log_info_tmp.txt','w+',encoding='utf-8',errors='ignore')
handlefile=open('debug/handle_log_info.txt','w+',encoding='utf-8',errors='ignore')
#calc reasonable range based on measured framerate
for line in infofile.readlines():
matchObj2 = re.search(r'measured.*', line)
if matchObj2:
str2=matchObj2.group()
min=float(str2.split(" ")[1])
max=float(str2.split(" ")[2])
min_range=((min+max) / 2) * 0.377 * coefficient
max_range=min_range * 2.2
min_range=int(min_range)
max_range=int(max_range)
line='range="'+str(min_range)+'-'+str(max_range)+'"\n'
#print(line)
calcfile.write(line)
calcfile.seek(0)
#splice info
string=calcfile.read()
x=re.sub(r'\ncodecinfo',' codecinfo',string,flags=re.S)
x=re.sub(r'\nrange',' range',x,flags=re.S)
handlefile.write(x)
calcfile.close()
pickfile.close()
handlefile.close()
3.modify_xml_range.py
#!/usr/bin/env python
#coding=utf-8
import os
import sys
import re
handlefile=open('debug/handle_log_info.txt','r+',encoding='utf-8',errors='ignore')
#lookin xml framerate and replace range
disturbfile=open('debug/media_codecs_performance_disturb.xml','r+',encoding='utf-8',errors='ignore')
modifyfile=open('debug/media_codecs_performance_modify.xml','w+',encoding='utf-8',errors='ignore')
cleanfile=open('debug/media_codecs_performance_clean.xml','r+',encoding='utf-8',errors='ignore')
finalfile=open('debug/media_codecs_performance_final.xml','w+',encoding='utf-8',errors='ignore')
disturblines=disturbfile.read()
addline=''
for line in handlefile.readlines():
matchObj = re.search(r'codecinfo.*', line)
if matchObj:
matchline=matchObj.group()
codec='"'+matchline.split(" ")[1]+'"'
resutionline='.*measured-frame-rate-'+matchline.split(" ")[2]+'.*?\/\>'
raterange=matchline.split(" ")[3]
#print(matchline.split(" ")[1]+'|'+matchline.split(" ")[2]+'|'+matchline.split(" ")[3])
codecpattern = codec+'.*?MediaCodec'
matchObj2 = re.search(codecpattern,disturblines,re.S)
if matchObj2:
codeclines = matchObj2.group()
matchObj3 = re.search(resutionline,codeclines)
if matchObj3:
#print(matchObj3.group())
rangeline = re.sub(r'range="1-2"',raterange, matchObj3.group())
addline = rangeline
#print(rangeline)
modifycodec= re.sub(matchObj3.group(),rangeline, codeclines)
#print(modifycodec)
disturblines=re.sub(codecpattern,modifycodec,disturblines,flags=re.S)
#print(disturblines)
else:
matchObj4 = re.search('.*measured-frame-rate-',addline)
if matchObj4:
tmpline = matchObj4.group()+matchline.split(" ")[2]+'" '+matchline.split(" ")[3]+' />'
addline2 = addline+'\n'+tmpline
#print(addline2)
modifycodec= re.sub(addline,addline2, codeclines,re.S)
#print(modifycodec)
disturblines=re.sub(codecpattern,modifycodec,disturblines,flags=re.S)
#print(disturblines)
print(matchline.split(" ")[1]+" no match resulotion: "+matchline.split(" ")[2])
else:
print("no match codecinfo for :"+line)
modifyfile.write(disturblines)
modifyfile.seek(0)
#some decode was not tested, replace origin values
cleanlines=cleanfile.read()
disturb_line_patten='.*range="1-2".*'
for line in modifyfile.readlines():
if re.search('MediaCodec name',line) :
codeclines_pattern = line+'.*?\<\/MediaCodec\>'
matchObj5=re.search(codeclines_pattern,disturblines,re.S)
if matchObj5:
codeclines_modify=matchObj5.group()
while (re.search(disturb_line_patten, codeclines_modify)):
matchObj6 = re.search(disturb_line_patten, codeclines_modify)
if matchObj6:
disturb_line_modify = matchObj6.group()
#get resolution
matchObj7 = re.search('measured-frame-rate-.*?"',disturb_line_modify)
resulotion_pattern='null'
if matchObj7:
resulotion_pattern=matchObj7.group()
#print(disturb_line_modify)
#find origin value in clean xml
matchObj8=re.search(codeclines_pattern,cleanlines,re.S)
if matchObj8:
codeclines_clean=matchObj8.group()
resulotion_line_pattern=r'.*'+resulotion_pattern+'.*'
matchObj9=re.search(resulotion_line_pattern,codeclines_clean)
if matchObj9:
#print('find clean file '+matchObj9.group())
codeclines_modify=re.sub(disturb_line_modify,matchObj9.group(),codeclines_modify,re.S)
#print(codeclines_modify)
disturblines=re.sub(matchObj5.group(),codeclines_modify,disturblines,re.S)
#print('next codec')
finalfile.write(disturblines)
modifyfile.close()
disturbfile.close()
handlefile.close()
finalfile.close()
cleanfile.close()
anlysis_log.py:
#!/usr/bin/env python
#coding=utf-8
import os
import sys
import re
print(sys.version_info[:3])
originfile=open('debug/performance_log.txt','r+',encoding='utf-8')
pickfile=open('debug/performance_pick.txt','w+',encoding='utf-8')
tmpfile=open('debug/performance_pick_tmp.txt','w+',encoding='utf-8')
pattern=r'TestRunner: failed|TestRunner.*?Expected achievable frame rates|TestRunner: Measured frame rate'
for line in originfile.readlines():
x=re.sub(r'[^\x00-\x7F]+','', line) #remove non-ascii
matchObj = re.search(pattern, x)
if matchObj:
x=re.sub(r'.*?TestRunner: failed:','testcase',x)
x=re.sub(r'\(.*?\)','',x) #remove (android.media.cts.VideoDecoderPerfTest)
x=re.sub(r'.*?Expected achievable frame rates for','codecinfo',x)
x=re.sub(r'.*?Measured frame rate: ','measured ',x)
x=re.sub(r'video.*? ','',x)
x=re.sub(r',|\[|\]\.','',x) #remove ',[]'
x=re.sub(r'\:.*','',x) #remove config rate '[]'
pickfile.write(x)
#calc the frame rate range
pickfile.seek(0)
allline=''
for line2 in pickfile.readlines():
matchObj2 = re.search(r'measured.*', line2)
if matchObj2:
str2=matchObj2.group()
min=float(str2.split(" ")[1])
max=float(str2.split(" ")[2])
min_range=((min+max) / 2) * 0.377 * 0.9
max_range=min_range * 2.2
min_range=int(min_range)
max_range=int(max_range)
line2='range="'+str(min_range)+'-'+str(max_range)+'"\n'
#print(line2)
tmpfile.write(line2)
tmpfile.seek(0)
#splice info
string=tmpfile.read()
x=re.sub(r'\ncodecinfo',' codecinfo',string,flags=re.S)
x=re.sub(r'\nrange',' range',x,flags=re.S)
pickfile.seek(0)
pickfile.truncate()
pickfile.write(x)
#lookin xml framerate and replace range
xmlfile=open('debug/media_codecs_performance.xml','r+',encoding='utf-8')
targetxmlfile=open('debug/media_codecs_performance_fix.xml','w+',encoding='utf-8')
allinfo=xmlfile.read()
pickfile.seek(0)
for line3 in pickfile.readlines():
matchObj3 = re.search(r'codecinfo.*', line3)
if matchObj3:
str3=matchObj3.group()
codec='"'+str3.split(" ")[1]+'"'
resution='"measured-frame-rate-'+str3.split(" ")[2]+'"'
raterange=str3.split(" ")[3]
print(codec+'|'+resution+'|'+raterange)
codecpattern = codec+'.*?MediaCodec'
matchObj4 = re.search(codecpattern,allinfo,re.S)
if matchObj4:
str4=matchObj4.group()
print(str4)
#xmlfile.write(line3)
tmpfile.seek(0)
pickfile.close()
originfile.close()
边栏推荐
- Specificity and five applications of Worthington alcohol dehydrogenase
- Three modes of executing programs, memory and cache
- Safety management and application of genomic scientific data
- Origin and development of philosophy Hegel external historical form
- 10 commonly used data visualization tool software
- Document the use of anti shake in packaged components and projects
- 2022.7.20 linear table
- Custom type
- 【Power Shell】Invoke-Expression ,Invoke-Expression -Command $activateCommand; Error or power shell failed to activate the virtual environment
- What are the important trends revealed by the release of "operator data viability index"?
猜你喜欢
![[leetcode] 2. Add two numbers - go language problem solving](/img/26/9b5df9aedc34238ce816cbf8e72066.png)
[leetcode] 2. Add two numbers - go language problem solving

How to implement the server anti blackmail virus system is a problem we have to consider

Multithreading and high concurrency (II) -- synchronized locking and unlocking process

Tiktok iqiyi announced cooperation, long and short video handshake and reconciliation?

Harbor installation

Service address dynamic awareness of Nacos registry
![[recognize cloud Nativity] Chapter 4 cloud network section 4.9.4.3 - smart network card usage scenario - network acceleration implementation](/img/9a/b69036bf920706360d8b293dad2a89.png)
[recognize cloud Nativity] Chapter 4 cloud network section 4.9.4.3 - smart network card usage scenario - network acceleration implementation

Prosci 14-3-3 (phosphate ser58) antibody instructions

What is iftmcs indicating contract status message?
![Deamnet|filenotfounderror: [winerror 3] the system cannot find the specified path.: '/ Datasettest\\Set12‘](/img/7c/0af10dceb20c0b392d0bab749eb355.png)
Deamnet|filenotfounderror: [winerror 3] the system cannot find the specified path.: '/ Datasettest\\Set12‘
随机推荐
Speed comparison between 64 bit width and 32 bit width of arm64 memory
The difference between sigsuspend and sigwait
Peripherals: interrupt system of keys and CPU
The two supply chain centers of HEMA launched the "background" of innovative research and development of multi format commodities
Talk about resume optimization and interview skills of algorithm post!
On let variable promotion
[summer daily question] Luogu p1605 maze
G024-db-gs-ins-01 openeuler deployment opengauss (single instance)
Peripherals: timer, watchdog and RTC
Application status of typical marine environmental observation data products and Its Enlightenment to China
WhatsApp web for usability testing of software testing technology
Why is the exclude or include attribute setting of the < keep alive > component invalid
Three possible scenarios for SAP Spartacus server-side rendering
DotNetCore. Cap notes
Windows security hardening -- close unnecessary ports
Open source demo | release of open source example of arcall applet
Service address dynamic awareness of Nacos registry
Origin and development of philosophy Hegel external historical form
Google Earth engine - 1980 present global pressure, temperature, wind and other data sets
EasyX realizes button effect